SUM Function [Aggregate]

Returns the total of the specified expression for each group of rows.

Syntax

SUMexpression | DISTINCT column-name )

Parameters

Parameter

Description

expression

The object to be summed. This is commonly a column name.

DISTINCT column-name

Computes the sum of the unique values in column-name for each group of rows. This is of limited usefulness, but is included for completeness.

Returns

INTEGER

DOUBLE

NUMERIC

Example

The following statement returns the value 3749146.740:

SELECT SUM( salary )
FROM Employees

Usage

Rows where the specified expression is NULL are not included.

Returns NULL for a group containing no rows.

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Compatible with Adaptive Server Enterprise.

Related concepts
Windowing Aggregate Function Usage
Related reference
AVG Function [Aggregate]
COUNT Function [Aggregate]