Line Item Total
EasySQLDatabaseSorting
Description
Write a SQL query to return each line item id and its total, computed as price times quantity, ordered by id ascending. **Output columns (in order):** id, total
Table:
lineitems| Column | Type |
|---|---|
| id | INT |
| price | INT |
| quantity | INT |
Examples
Input:
CREATE TABLE lineitems (id INT, price INT, quantity INT); INSERT INTO lineitems VALUES (1,10,2),(2,5,3),(3,7,0);Output:
1|20
2|15
3|0Explanation:
Multiplying price by quantity for each row gives the per-line total returned by id.
Input:
CREATE TABLE lineitems (id INT, price INT, quantity INT); INSERT INTO lineitems VALUES (1,100,1);Output:
1|100Explanation:
Multiplying price by quantity for each row gives the per-line total returned by id.
Input:
CREATE TABLE lineitems (id INT, price INT, quantity INT); INSERT INTO lineitems VALUES (2,4,4),(1,3,3);Output:
1|9
2|16Explanation:
Multiplying price by quantity for each row gives the per-line total returned by id.
Constraints
- •
Use standard SQL (SQLite).