COUNT, SUM, AVG, MIN, MAX
Use the five core aggregate functions, understand COUNT(*) vs COUNT(column), and know how NULLs are treated by each.
What Aggregates Do
An aggregate function collapses many rows into one value. Examples: total revenue, average rating, max date.
COUNT
Counts rows. Two flavours:
SELECT COUNT(*) FROM users; -- counts ALL rows
SELECT COUNT(email) FROM users; -- counts rows where email IS NOT NULL
SELECT COUNT(DISTINCT country) FROM users; -- distinct non-NULL countriesAll lessons in this course
- COUNT, SUM, AVG, MIN, MAX
- GROUP BY Single and Multiple Columns
- HAVING vs WHERE
- Common Pitfalls: NULLs in Aggregates