SUM Function

Returns the sum of all the values in an expression.

Categories: Aggregate
Descriptive Statistics
Returned data type: The same data type as the expression

Syntax

Arguments

expression

specifies any valid SQL expression.

Requirement The result of the SUM function must be within the range of the data type.
Data type BIGINT, DOUBLE, FLOAT, INTEGER, REAL, SMALLINT, TINYINT
See <sql-expression>
FedSQL Expressions

Details

Null values and SAS missing values are ignored and are not included in the computation.
You can use an aggregate function to produce a statistical summary of data in the entire table that is listed in the FROM clause or for each group that is specified in a GROUP BY clause. The GROUP BY clause groups data by a specified column or columns. When you use a GROUP BY clause, the aggregate function in the SELECT clause or in a HAVING clause instructs FedSQL in how to summarize the data for each group. FedSQL calculates the aggregate function separately for each group. If GROUP BY is omitted, then all the rows in the table or view are considered to be a single group.

Example

The following statements illustrate the SUM function:
Statements
Results
select sum(density) from densities;
1728.324
select sum(population) from densities;
1.2278E8

See Also

SELECT Statement Clauses: