Skip to main contentSkip to solution

The HAVING clause is used to filter the groups based on _______ function results.

Solution

✅ Correct Option: 1

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question