Skip to content

Counting and averaging

Handout

Summarising with aggregate functions

Sometimes you do not want the rows themselves, but a summary of them. Aggregate functions turn many rows into a single value:

  • COUNT(*) — how many rows
  • SUM(col) — the total
  • AVG(col) — the average
  • MIN(col) / MAX(col) — the smallest / largest
SELECT COUNT(*) FROM student;

COUNT, SUM and AVG reduce a whole column to a single number each

Handout

Log in or create account

IGCSE & A-Level