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.

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