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
You can’t use the Alias “Avg_Cost” in a Group By clause..
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
Caz is right.
Only the Order By clause can use alias cloumns from the select statement.
See http://oracle.readthedocs.org/en/latest/sql/basics/query-processing-order.html for details
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.
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
But also B is correct: promo_category is not group
[Error] Execution (3: 8): ORA-00937: not a single-group group function
C is corret, sorry