Guided Notes

Aggregate Functions & GROUP BY

COUNT, SUM, AVG, MIN, MAX, GROUP BY, HAVING, and aliasing.

Aggregate functions

Slide 1 / 5

Aggregate functions take many rows and return one value:

COUNT() β€” how many rows SUM() β€” total AVG() β€” average MIN() / MAX() β€” smallest / largest

SELECT COUNT(id) FROM comments;

returns a single number: how many comments there are. On its own, an aggregate summarizes the whole table β€” GROUP BY lets it summarize per group.

← Filtering with WHERE