Aggregate functions

Some queries examine aspects of the data in your table that reflect properties of groups of rows rather than of individual rows. For example, you may want to find the average amount of money that a customer pays for an order, or to see how many employees work for each department. For these types of tasks, you use aggregate functions and the GROUP BY clause.

Aggregate functions return a single value for a set of rows. If there is no GROUP BY clause, an aggregate function returns a single value for all the rows that satisfy other aspects of the query.

List the number of employees in the company
List the number of employees in the company and the birth dates of the oldest and youngest employee

The functions COUNT, MIN, and MAX are called aggregate functions. Aggregate functions summarize information. Other aggregate functions include statistical functions such as AVG, STDDEV, and VARIANCE. All but COUNT require a parameter. See Aggregate functions.


Applying aggregate functions to grouped data
Restricting groups
Combining WHERE and HAVING clauses