SQL Server SUM() Function
THE WORLD'S LARGEST WEB DEVELOPER SITE

SQL Server SUM() Function

❮ SQL Server Functions

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 returns the summed value of an expression.

Syntax

SUM(expression)

Parameter Values

Parameter Description
expression Required. A numeric value (can be a field or a formula)

Technical Details

Works in: SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005

❮ SQL Server Functions