GK Question

technology medium mcq

Which SQL clause is used to filter groups after aggregation?

  1. WHERE
  2. HAVING
  3. GROUP BY
  4. ORDER BY

Answer: HAVING

HAVING clause filters results after GROUP BY aggregation, while WHERE filters rows before grouping. Example: SELECT dept, AVG(salary) FROM emp GROUP BY dept HAVING AVG(salary) > 50000. WHERE cannot be used with aggregate functions directly.

Topic Database & Programming
Exam Relevance Banking, SSC JE, Railway