HAVING
noun
say it: “HAV-ing” /ˈhævɪŋ/
The part of a query that filters groups after GROUP BY, using aggregate values.
What is HAVING in a relational database?
HAVING — A clause filtering groups after grouping and aggregation.
SELECT customer_id, COUNT(*) AS order_count
FROM purchase_order
GROUP BY customer_id
HAVING COUNT(*) >= 3;
In a sentence
- “HAVING COUNT(*) > 5 keeps only countries with more than five customers.”
Level: Apprentice · More SQL terms at this level
Updated