Total Quantity Sold
EasySQLDatabaseSorting
Description
Write a SQL query to return the total quantity sold across all rows of the sales table as a single value named total. **Output columns (in order):** total
Table:
sales| Column | Type |
|---|---|
| id | INT |
| product | TEXT |
| quantity | INT |
Examples
Input:
CREATE TABLE sales (id INT, product TEXT, quantity INT); INSERT INTO sales VALUES (1,'A',3),(2,'B',5),(3,'A',2);Output:
10Explanation:
Summing the quantity column across every row gives the single total returned.
Input:
CREATE TABLE sales (id INT, product TEXT, quantity INT); INSERT INTO sales VALUES (1,'A',10);Output:
10Explanation:
Summing the quantity column across every row gives the single total returned.
Input:
CREATE TABLE sales (id INT, product TEXT, quantity INT); INSERT INTO sales VALUES (1,'A',0),(2,'B',0);Output:
0Explanation:
Summing the quantity column across every row gives the single total returned.
Constraints
- •
Use standard SQL (SQLite).