When do we use a HAVING clause?
Correct answer
B. To limit the output of a query using an aggregate function only
19 views
B. To limit the output of a query using an aggregate function only
19 views
HAVING is used to limit the output of a query using an aggregate function. WHERE filters individual rows before grouping and cannot contain aggregates such as COUNT() or SUM(); HAVING filters the groups afterwards.
Example: SELECT dept, COUNT(*) FROM staff GROUP BY dept HAVING COUNT(*) > 5;.
Practise more Database Management Systems MCQs with answers and explanations on MCQsExam.com.
Not sure why the answer is B? Ask here and get an explanation.