SQL Server SUM() Function
Example
Return the sum of the "Quantity" field in the "OrderDetails" table:
SELECT SUM(Quantity) AS TotalItemsOrdered FROM OrderDetails;
Try it Yourself »
Definition and Usage
The SUM() function calculates the sum of a set of values.
Note: NULL values are ignored.
Syntax
SUM(expression)
Parameter Values
| Parameter | Description |
|---|---|
| expression | Required. A field or a formula |
Technical Details
| Works in: | SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse |
|---|
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.