Skip to content

Latest commit

 

History

History
52 lines (44 loc) · 2.86 KB

aggregate-functions-transact-sql.md

File metadata and controls

52 lines (44 loc) · 2.86 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords dev_langs monikerRange
Aggregate Functions (Transact-SQL)
Aggregate Functions (Transact-SQL)
markingmyname
maghan
08/15/2018
sql
t-sql
reference
functions [SQL Server], aggregate
aggregate functions [SQL Server], about aggregate functions
summarizing functions
aggregate functions [SQL Server]
TSQL
>= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current||=fabric

Aggregate Functions (Transact-SQL)

[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw]

An aggregate function performs a calculation on a set of values, and returns a single value. Except for 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. In other words, aggregate functions return the same value each time that they are called, when called with a specific set of input values. See Deterministic and Nondeterministic Functions for more information about function determinism. The OVER clause may follow all aggregate functions, except the STRING_AGG, GROUPING or GROUPING_ID functions.

Use aggregate functions as expressions only in the following situations:

  • The select list of a SELECT statement (either a subquery or an outer query).
  • A HAVING clause.

[!INCLUDEtsql] provides the following aggregate functions:

See also

Built-in Functions (Transact-SQL)
OVER Clause (Transact-SQL)