SQL with SUM, COUNT and more

About this lesson: SQL with SUM, COUNT and more

In short

Aggregate functions turn many records into one answer.

SQL with SUM, COUNT and more

What you'll explore

Aggregate functions: COUNT and MAX
Aggregate functions turn many records into one answer.
SUM, AVERAGE, MIN, MAX: Spreadsheet comparison
The same ideas appear in spreadsheets.
Filtering first: WHERE then aggregate
WHERE chooses records before COUNT or SUM works on them.
Two tables: JOIN, then filter
Real databases join tables with keys before filtering.
Check yourself: COUNT
SELECT COUNT(*) FROM Planets WHERE Rocky = FALSE;

Also in this lesson

  • Step by step
  • Watch out for these
  • More than the lesson
  • Stretch your brain
  • Try it yourself

Words to know

Aggregate function
Summarises many rows into one value.
SUM
Adds values.
COUNT
Counts rows.
AVG
Finds the mean.
WHERE
Filters rows.

Sources

  • SQLite documentation: aggregate functions
  • Raspberry Pi Foundation, Isaac Computer Science: SQL
  • W3C/ISO SQL standard overview
  • BBC Bitesize, GCSE Computer Science: SQL

An interactive lesson with a live experiment: move the sliders, press the buttons and answer quick questions. 5 short steps and a 8-question quiz. Part of the Family plan. Written and checked by Shalo Lab. Last updated 11 November 2026.

Automated control systems →

All lessons in Term 2 · Computing · Age 15