Q&A
Q&AWhat is the difference between WHERE and HAVING?
WHERE filters input rows before grouping; HAVING filters groups after aggregation.
Read the concise answer
Use WHERE to remove rows before GROUP BY, such as excluding inactive employees. Use HAVING to filter aggregate results, such as departments with COUNT(*) greater than five. Moving a condition between them can change both meaning and query work.