ISC SQL · Updated November 2026
WHERE vs HAVING: Why Do They Both Filter Data?
WHERE filters individual rows. HAVING filters groups after aggregation.
WHERE
WHERE filters individual rows before grouping, such as including only transactions above a certain amount.
GROUP BY
GROUP BY combines rows into groups for aggregate analysis, such as total sales by customer.
HAVING
HAVING filters the grouped results, such as customers whose total sales exceed a threshold.
ORDER BY
ORDER BY sorts the final result. It does not decide which records qualify.
Aggregate functions
Common functions include SUM, COUNT, AVG, MIN, and MAX.
The takeaway
Raw-record condition? WHERE. Aggregate-result condition? HAVING.
Related Summit guides
FAQ
Can WHERE filter aggregate results the same way as HAVING?
Generally no.
What does GROUP BY do?
Creates groups for aggregate analysis.
Does ORDER BY filter records?
No.
