Question:

SQL applies conditions on the groups through ________ clause after groups have been formed?

Updated On: Mar 29, 2025
  • where
  • having
  • new
  • all
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

SQL Group Filtering: SQL provides different clauses for filtering data at different stages of query execution.

Key Differences:

  • WHERE (Option 1): Filters rows before grouping occurs
  • HAVING (Option 2): Filters groups after they are formed
  • NEW (Option 3): Not a valid SQL clause for filtering
  • ALL (Option 4): A keyword used with comparison operators, not for group filtering

Example Demonstration:

SELECT department, AVG(salary) FROM employees GROUP BY department HAVING AVG(salary) > 50000;  ← Filters after grouping

Why HAVING is correct:

  • Operates on aggregated data
  • Used with GROUP BY to filter group results
  • Can use aggregate functions (COUNT, SUM, AVG etc.) in conditions

The correct answer is (2) having, as it's the only clause that applies conditions after groups are formed.

Was this answer helpful?
0
0