Aggregate Functions

Lesson 8 of 20

Six rows in, one number out — watch COUNT, SUM, AVG, MIN and MAX squeeze a whole table into a single row.

The big picture

Many rows in, one number out

Aggregates are squeeze functions: COUNT, SUM, AVG, MIN and MAX collapse a whole column of rows into a single value.

COUNT(*)

Counts how many rows survived the query — the quickest popularity test there is.

SUM & AVG

SUM adds the values up; AVG divides the sum by how many values there were.

MIN & MAX

The smallest and largest value — the two boundaries of the column.

One row out

Without GROUP BY, an aggregate query returns exactly one summary row.