Skip to main contentSkip to solution

The HAVING clause is used to filter groups based on which function results?

Solution

✅ Correct Option: 2

The HAVING clause filters groups created by GROUP BY, based on the results of aggregate functions such as COUNT, SUM, AVG, MAX and MIN. For example, HAVING SUM(salary) > 50000\text{HAVING SUM(salary) > 50000} keeps only those groups whose total salary exceeds 50000.

WHERE filters individual rows before grouping and cannot use aggregate functions. HAVING filters groups after grouping and can.


Option 3: window functions (such as RANK or ROW_NUMBER) are not allowed directly in HAVING. They are evaluated after it, so they cannot be used to filter groups there.

Keyboard Shortcuts

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