Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

SUM

Example

Retrieve the total sum of the “Quantity” values from the “OrderDetails” table.

SELECT SUM(Quantity) AS TotalItemsOrdered FROM OrderDetails;

Definition and Usage

The SUM() function computes the total sum of a specified set of values.

Note: The SUM() function disregards NULL values in its calculation.

Syntax

SUM(expression)

Parameter Values

Parameter

Description

expression

Required: A field or an expression representing the values to be summed.

Technical Details

Works in:

SQL Server (beginning from 2008), Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse