The SUM()
function returns the total sum of a numeric column.
SELECT SUM(column_name)
FROM table_name
WHERE condition;
The parameter inside the SUM()
function can also be an expression.
If we assume that each product in the OrderDetails
column costs 10 dollars, we can find the total earnings in dollars by multiply each quantity with 10:
SELECT SUM(Quality * 10)
FROM OrderDetails;