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 10, 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:
  • \texttt{SUM()}
  • \texttt{COUNT()}
  • \texttt{AVG()}
  • \texttt{MAX()}
  • \texttt{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: \[ \texttt{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: \[ \texttt{SELECT Department, COUNT(*)} \] \[ \texttt{FROM Employees} \] \[ \texttt{GROUP BY Department} \] \[ \texttt{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: \[ \text{HAVING} \]
Was this answer helpful?
0
0