Which clause in the above SQL statement causes the error?

View the Exhibit and examine the structure of the PROMOTIONS table.
Evaluate the following SQL statement:
SQL>SELECT promo_category, AVG(promo_cost) Avg_Cost, AVG(promo_cost)*.25 Avg_Overhead
FROM promotions
WHERE UPPER(promo_category) IN (‘TV’, ‘INTERNET’,’POST’)
GROUP BY Avg_Cost
ORDER BY Avg_Overhead;
The above query generates an error on execution.
Which clause in the above SQL statement causes the error?

View the Exhibit and examine the structure of the PROMOTIONS table.

Evaluate the following SQL statement:
SQL>SELECT promo_category, AVG(promo_cost) Avg_Cost, AVG(promo_cost)*.25 Avg_Overhead
FROM promotions
WHERE UPPER(promo_category) IN (‘TV’, ‘INTERNET’,’POST’)
GROUP BY Avg_Cost
ORDER BY Avg_Overhead;
The above query generates an error on execution.

Which clause in the above SQL statement causes the error?

A.
WHERE

B.
SELECT

C.
GROUP BY

D.
ORDER BY



Leave a Reply 7

Your email address will not be published. Required fields are marked *


Caz

Caz

You can’t use the Alias “Avg_Cost” in a Group By clause..

amruta

amruta

c is correct because in select promo_category is without group function so it should be use in group by clause tell me i am right or wrong

Sayed

Sayed

The main reason of the error is not using the alias (yes it is an issue). The GROUP BY clause must have the promo_category to justify the grouping.

Emily

Emily

c is correct because,any column or expression in the select clause list that is not an aggregate function must be in the group function,i.e the promo_category
And alias should not be used in the group by clause

Anand

Anand

But also B is correct: promo_category is not group

[Error] Execution (3: 8): ORA-00937: not a single-group group function

Anand

Anand

C is corret, sorry