After groups have been established, SQL applies predicates in the ____ clause,…
2023
After groups have been established, SQL applies predicates in the ____ clause, allowing aggregate functions to be used.
- A.
HAVING
- B.
GROUP BY
- C.
WITH
- D.
More than one of the above
- E.
None of the above
Attempted by 1304 students.
Show answer & explanation
Correct answer: A
After groups are formed using the GROUP BY clause, SQL uses the HAVING clause to apply conditions (predicates) on those groups. Unlike the WHERE clause, which filters rows before grouping, HAVING filters groups after aggregation. This allows the use of aggregate functions such as SUM, COUNT, AVG, etc., in the filtering condition. For example, you can use HAVING COUNT(*) > 5 to filter only those groups that have more than 5 rows. Therefore, the correct answer is HAVING.