GROUP BY: per-category summaries
One summary row per group.
Summarize per group
GROUP BY splits rows into groups and runs the aggregate once per group. "How many books per genre?":
SELECT genre, COUNT(*) AS books
FROM books
GROUP BY genre;
The rule: every column in the SELECT must either be in the GROUP BY or wrapped in an aggregate. (Postgres will tell you off otherwise.) You can group by several columns to get one row per combination.