Aggregate Functions
Aggregate functions perform a calculation on a set of values and return a single value. With the exception of COUNT, aggregate functions ignore null values. Aggregate functions are often used with the GROUP BY clause of the SELECT statement.
All aggregate functions are deterministic; they return the same value any time they are called with a given set of input values. For more information about function determinism, see Deterministic and Nondeterministic Functions.
Aggregate functions are allowed as expressions only in:
- The select list of a SELECT statement (either a subquery or an outer query).
- A COMPUTE or COMPUTE BY clause.
- A HAVING clause.
The Transact-SQL programming language provides these aggregate functions:
AVG | MAX |
BINARY_CHECKSUM | MIN |
CHECKSUM | SUM |
CHECKSUM_AGG | STDEV |
COUNT | STDEVP |
COUNT_BIG | VAR |
GROUPING | VARP |