QuestionQ76

VerifiedUsing Single-Row and Aggregate Functions

The sales table contains the numeric columns PROD_ID and QUANTITY_SOLD.

Which two queries run successfully?

Choose two
Explanation

A SELECT statement must specify the WHERE clause before GROUP BY, and GROUP BY before HAVING; aggregate functions such as COUNT() are evaluated after row filtering and therefore can only appear in the SELECT list or HAVING clause, never in WHERE. Queries A and D follow this required clause order and correctly avoid placing an aggregate function in the WHERE clause, so both execute successfully, while B has an invalid clause order and C and E illegally reference COUNT() in WHERE.

Learn more

Community Discussion

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