Skip to main content
HAVING filters the grouped results by their totals. Where WHERE runs before grouping and looks at individual rows, HAVING runs after grouping and looks at each group’s aggregated metrics.
This keeps only the vendors whose total revenue tops 1,000. HAVING uses the same operators and AND / OR logic as WHERE, so you can combine conditions.
Because it acts on group totals, HAVING needs a GROUP BY. To cap how many groups you keep once they are filtered and sorted, add ORDER BY and LIMIT.