Aggregate functions collapse many rows into a single summary value. They answer "how many?", "what's the total?", "what's the average?" — the questions businesses ask constantly.
The five you need
SELECTCOUNT(*) AS n_students, -- number of rowsCOUNT(email) AS n_with_email, -- non-NULL emailsAVG(package) AS avg_package,MAX(package) AS top_package,MIN(package) AS lowest,SUM(package) AS totalFROM students;
Key takeaways
- 01Aggregate functions collapse many rows into one summary value.
- 02COUNT, SUM, AVG, MIN, MAX are the core five.
- 03COUNT(*) counts rows; COUNT(col) counts non-NULL values.
- 04Aggregates ignore NULLs (except COUNT(*)).
