QuestionQ1

VerifiedReporting Aggregated Data Using the Group Functions

Examine the description of the EMPLOYEES table:

Question Image

Which statement will fail?

Explanation

Aggregate functions cannot be evaluated in the WHERE clause, because WHERE filters individual rows before any groups exist; a condition such as COUNT(*) >= 3 there raises ORA-00934: group function is not allowed here. Group-level filtering belongs in the HAVING clause, and Oracle permits the HAVING clause to be written either before or after GROUP BY, so the statements placing HAVING ahead of GROUP BY execute successfully, as does the conventional WHERE … GROUP BY … HAVING form.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!