Question:

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

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

The Correct Option is B

Approach Solution - 1

In SQL, when applying conditions to grouped data, the HAVING clause is used. This clause is executed after the data has been grouped by the GROUP BY clause, allowing you to filter groups based on a specified condition. Unlike the WHERE clause, which is used to filter rows before they are grouped, the HAVING clause is applied to each group of grouped data.
The correct answer for this SQL condition application is:
  • HAVING
Was this answer helpful?
0
0
Hide Solution
collegedunia
Verified By Collegedunia

Approach Solution -2

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