WHERE runs before grouping, so it cannot filter on a count or an average. HAVING filters the groups after GROUP BY, like keeping only departments with more than 5 employees. Use HAVING for conditions on aggregates and WHERE for conditions on single rows. Mixing the two up is a classic interview question, so know the order in which SQL runs them.