Question:

In SQL, which clause is used to filter the results of an aggregate function?

Show Hint

{WHERE} filters rows before grouping, while {HAVING} filters results after aggregate functions are applied.
Updated On: Mar 16, 2026
  • WHERE
  • GROUP BY
  • HAVING
  • ORDER BY
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Concept: In SQL, aggregate functions such as:

  • SUM()
  • COUNT()
  • AVG()
  • MAX()
  • MIN()

are used to perform calculations on a set of rows and return a single result.

To filter results based on aggregate values, SQL uses the HAVING clause.

Step 1: Understand the WHERE clause.
The WHERE clause filters rows before grouping takes place.

Example:
 


SELECT * FROM Employees WHERE Salary > 50000;

It cannot be used with aggregate functions directly.

Step 2: Understand the HAVING clause.
The HAVING clause is used to filter results after aggregation.

Example:


SELECT Department, COUNT(*)
FROM Employees
GROUP BY Department
HAVING COUNT(*) > 5;

This query returns only those departments having more than 5 employees.

Step 3: Conclusion.
Since filtering conditions applied to aggregate functions are handled using the HAVING clause, the correct answer is:

HAVING

Was this answer helpful?
0
0