112.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
答案:C
解析:列别名,不能用于where中,group by中,这其实是一个sql语句执行顺序的问题
1.from
2.where
3.group by
4.having
5.select
6.order by子句
通过这个可以知道order by 可以使用列别名
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
答案:C
解析:列别名,不能用于where中,group by中,这其实是一个sql语句执行顺序的问题
1.from
2.where
3.group by
4.having
5.select
6.order by子句
通过这个可以知道order by 可以使用列别名