Ever tried filtering on COUNT() with WHERE and hit a confusing error?
The problem: WHERE runs before GROUP BY, so aggregate functions don't exist yet. That's where HAVING comes in. It filters after grouping.
WHERE = filter individual rows
HAVING = filter aggregates
Read more: https://jamalhansen.com/blog/having-filtering-grouped-results
