The HAVING clause is used to filter the groups based on _______ function results.
The HAVING clause is used to filter the groups based on _______ function results.
Solution
HAVING filters the groups created by GROUP BY, and it does so using aggregate functions such as COUNT(), SUM(), AVG(), MIN() and MAX(). For example, HAVING COUNT(*) > 5 keeps only the groups with more than 5 rows.
WHERE filters individual rows before grouping and cannot use aggregate functions. HAVING filters groups after grouping.
Option 2: a subquery can appear inside a HAVING condition, but HAVING is defined to filter on aggregate results, not on subqueries.
Option 3: window functions are not allowed in HAVING. They are evaluated after it, so they can appear only in SELECT and ORDER BY.
Related questions:
2026: 23 May Shift 1
2026: 18 May Shift 2