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
ColumnType
idINT
productTEXT
quantityINT

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:10
Explanation:

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:10
Explanation:

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:0
Explanation:

Summing the quantity column across every row gives the single total returned.

Constraints

  • Use standard SQL (SQLite).

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.