Skip to content

Latest commit

 

History

History
52 lines (44 loc) · 2.68 KB

File metadata and controls

52 lines (44 loc) · 2.68 KB
title Aggregate Functions (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 07/24/2017
ms.prod sql-non-specified
ms.reviewer
ms.suite
ms.technology
database-engine
ms.tgt_pltfrm
ms.topic language-reference
dev_langs
TSQL
helpviewer_keywords
functions [SQL Server], aggregate
aggregate functions [SQL Server], about aggregate functions
summarizing functions
aggregate functions [SQL Server]
ms.assetid 0c06ae42-eb0a-4d77-9d74-aa1e7f344009
caps.latest.revision 30
author BYHAM
ms.author rickbyh
manager jhubbard

Aggregate Functions (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2008-all_md]

Aggregate functions perform a calculation on a set of values and return a single value. Except for COUNT, aggregate functions ignore null values. Aggregate functions are frequently used with the GROUP BY clause of the SELECT statement.

All aggregate functions are deterministic. This means aggregate functions return the same value any time that they are called by using a specific set of input values. For more information about function determinism, see Deterministic and Nondeterministic Functions. The OVER clause may follow all aggregate functions except GROUPING and GROUPING_ID.

Aggregate functions can be used as expressions only in the following:

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

[!INCLUDEtsql] provides the following aggregate functions:

AVG MIN
CHECKSUM_AGG SUM
COUNT STDEV
COUNT_BIG STDEVP
GROUPING VAR
GROUPING_ID VARP
MAX

See also

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