WHERE vs HAVING
Only rows that pass WHERE enter groups.
Only rows that passed WHERE are placed into group buckets.
4 kept rows form 3 groups in first-seen order.
HAVING examples are tiny finite group-filter transforms; SQL dialect completeness, optimizer behavior, indexing, and product claims are out of scope.
The bucket table names the exact source rows in each group.
GROUP BY works after the row filter has finished.