Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Reference » SQL Functions » Alphabetical list of functions

SUBSTRING function [String] Next Page

SUM function [Aggregate]

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

Syntax 1

SUM( expression | DISTINCT expression )

Syntax 2

SUM( expression ) OVER ( window-spec )

window-spec : see Syntax 2 instructions in the Usage section below


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

DISTINCT expression    Computes the sum of the unique values of expression in the input.


Rows where the specified expression is NULL are not included.

Returns NULL for a group containing no rows.

Syntax 2 represents usage as a window function in a SELECT statement. As such, elements of window-spec can be specified either in the function syntax (inline), or in conjunction with a WINDOW clause in the SELECT statement. See the window-spec definition provided in WINDOW clause.

For more information about using window functions in SELECT statements, including working examples, see Window functions.

See also
Standards and compatibility

The following statement returns the value 3749146.740.

SELECT SUM( Salary )
FROM Employees;