Aggregation & GROUP BY · SQL SQL
What is the primary purpose of the SQL HAVING clause in an aggregation query?
Practice question from Aggregation & GROUP BY (SQL SQL), with the correct answer and a step-by-step solution.
easy · MCQ · Q-C37B6C
What is the primary purpose of the SQL HAVING clause in an aggregation query?
- A.To filter individual rows before any grouping or aggregation takes place.
- B.To filter groups based on aggregate function results after the GROUP BY phase.Correct answer
- C.To sort the final result set in ascending or descending order.
- D.To join two or more tables based on a common column.
Solution
The HAVING clause is evaluated after the GROUP BY phase, allowing you to filter groups based on the results of aggregate functions (like SUM, COUNT, AVG). In contrast, the WHERE clause filters individual rows before grouping occurs.
More from Aggregation & GROUP BY
- Consider a table named 'employees' with columns 'department' and 'salary'. Which of the following queries correctly returns the average sal…
- In standard SQL (ANSI SQL), if an aggregate function such as SUM() or COUNT() is used in a SELECT list, what rule applies to any other non-…
- How do standard SQL aggregate functions (such as COUNT, SUM, AVG) handle NULL values in their input columns?
- What will be the output of COUNT() versus COUNT(columnname) when the specified column contains several NULL values?
Practise more SQL
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed