Mega Code Archive

 
Categories / MSSQL Tutorial / Aggregate Functions
 

Aggregate functions are applied to a group of data values from a column

Aggregate functions always  return a single value.  The Transact-SQL language supports six aggregate functions: AVG MAX MIN SUM COUNT COUNT_BIG AVG (short for average) calculates the arithmetic mean of the data values contained within a column. The column must contain numeric values.  MAX calculates the maximum, and MIN the minimum, data value of the column.  The column can contain numeric, string, and date/time values. SUM calculates the total of all data values in a column.  The column must contain numeric values.  COUNT calculates the number of (non-null) data values in a column.  The only aggregate function not being applied to columns is COUNT(*).  This function returns the number of rows (whether or not particular columns have null values).  COUNT_BIG function is analogous to the COUNT function.  The only difference is that COUNT_BIG returns a value of the BIGINT data type.