Business analysis glossary
HAVING Clause
What it is
The HAVING clause filters groups after GROUP BY has combined rows, using conditions on aggregate values such as COUNT or SUM. For example, it can keep only customers with more than three orders. WHERE filters rows before grouping; HAVING filters the groups afterwards.
Why it matters
Many analysis questions are about groups that meet a threshold, such as branches with more than fifty complaints or products returned more than ten times. Knowing HAVING lets analysts answer them directly in SQL, and confusing it with WHERE is a common interview question.
Example
The analyst finds customers who raised more than three disputes in a quarter by grouping disputes by customer with GROUP BY and keeping groups with HAVING COUNT of disputes greater than three. Twelve customers appear, and the fraud team reviews them the same week.