What is Aggregate Function?

An aggregate function summarises many rows into one value, such as COUNT, SUM, AVG, MIN or MAX.

Aggregate Function explained

Aggregates are the arithmetic of analysis: how many orders, total revenue, the average basket, the earliest date. Combined with GROUP BY they produce a summary per category.

Most aggregates ignore nulls, so AVG of a column with missing values averages only the rows that have one, which is a decision worth making deliberately.

Example

SELECT COUNT(*), SUM(amount), AVG(amount) FROM orders returns the number of orders, total revenue and average order value.

Frequently asked questions

What is Aggregate Function?
An aggregate function summarises many rows into one value, such as COUNT, SUM, AVG, MIN or MAX.
Can you give an example of Aggregate Function?
SELECT COUNT(*), SUM(amount), AVG(amount) FROM orders returns the number of orders, total revenue and average order value.