Retrieve the total sum of the “Quantity” values from the “OrderDetails” table.
SELECT SUM(Quantity) AS TotalItemsOrdered FROM OrderDetails; |
The SUM() function computes the total sum of a specified set of values.
Note: The SUM() function disregards NULL values in its calculation.
SUM(expression) |
Parameter |
Description |
expression |
Required: A field or an expression representing the values to be summed. |
Works in: |
SQL Server (beginning from 2008), Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse |