Skip to main content

Aggregate Functions in SQL SERVER

Aggregate Functions

These functions perform an operation on a set of fields and return a single value. Their use is relatively limited. They can be used in the following situations:

  • The selection list of the SELECT statement
  • A HAVING clause
  • A COMPUTE clause
Function                                                                                     Description

AVG ([ALL| DISTINCT] expression)Returns the average value in the group.
COUNT( [ALL|DISTINCT] expression) Counts the number of items in the group.
COUNT_BIG( [ ALL|DISTINCT] expression) Counts the number of items in the group. the result is returned in the form of bigint number.
GROUPING(Column_Name)Creates an additional column with a value of 1 operator or 0 if it is not the result of a CUBE or ROLLUP operator.
MAX( expression) Returns the maximum value in the expression.
MIN( expression)Returns the minimum value in the expression.
SUM ( expression)returns the sum of the expression's value.
STDEV (expression)Returns the statistical standard deviation for the values in the expression.
VAR (expression) Returns the statistical variance of the values in the expression.

Comments