» Documentation » SQL Reference

Grouping Functions

__NOTOC__ These functions are used for aggregating column data together. They are used with a SELECT's GROUP BY clause. Where all of the GROUP BY columns for a number of rows are equal, one row is returned, and all of the non-group by columns that would be returned can be processed by these grouping (or aggregation) functions.

COUNT

Syntax

COUNT(['column_name']) 

Returns the number of fields selected for the column name given. If the column name argument is omitted, or a '*' is used all ungrouped rows will be counted.

SUM

Syntax

SUM('column_name') 

Returns the numerical sum of the values of the fields selected for the column name given. This will only work with numeric columns.

AVG

Syntax

AVG('column_name') 

Returns the average (or "mean") value of the fields selected for the column name given. This will only work with numeric columns.

MIN

Syntax

MIN('column_name') 

Returns minimum value for the column name given.

MAX

Syntax

MAX('column_name') 

Returns maximum value for the column name given.