Beginner level · Module 4: Aggregation and Reporting Queries · Lesson 1 of 3
Aggregate Functions
Count, total, average and find the extremes of data with aggregate functions.
In this lesson you will
- Use COUNT, SUM, AVG, MIN and MAX
- Explain how aggregates treat NULL
Key concepts
COUNT(*) vs COUNT(column)SUM and AVGMIN and MAXNULL in aggregates
The lesson
Aggregate functions turn many rows into one value: COUNT(*) counts rows, SUM(amount) totals, AVG(amount) averages, and MIN and MAX find the smallest and largest values.
COUNT(*) counts all rows; COUNT(phone) counts only rows where phone is not NULL. AVG ignores NULLs, which can make an average look higher than expected if missing values should really be zero.
Combine aggregates with WHERE: SELECT SUM(amount) FROM payments WHERE paid_on >= '2026-03-01' totals payments since March.
Step by step
- Count all students and students with a phone number.
- Total and average all payments.
- Find the smallest and largest payment.
- Total payments for one month with WHERE.
Practice activity
Calculate the school's headline figures: number of students, total collected, average payment and largest payment.
Expected result: All figures match a hand calculation on the sample data.
Check your understanding
-
What is the difference between COUNT(*) and COUNT(phone)?
Show answer
COUNT(*) counts all rows; COUNT(phone) counts rows where phone is not NULL.
-
Does AVG include NULL values?
Show answer
No; it ignores them.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.