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

本文通过一个具体的SQL案例,展示了如何使用CASE语句结合AVG函数来计算不同条件下的平均成本。此方法适用于对特定区间的数据进行分组统计。
99.View the Exhibit and examine the structure of the PROMOTIONS table.


Using the PROMOTIONS table, you need to find out the average cost for all promos in the ranges
$0-2000 and $2000-5000 in category A
You issue the following SQL statement:


SQL>SELECT AVG(CASE WHEN promo_cost BETWEEN 0 AND 2000 AND promo_category='A'
then promo_cost ELSE null END) "CAT_2000A",
AVG(CASE WHEN promo_cost BETWEEN 2001 AND 5000 AND promo_category='A'
THEN promo_cost ELSE null END) "CAT_5000A"
FROM promotions;
What would be the outcome?
A.It executes successfully and gives the required result.
B.It generates an error because NULL cannot be specified as a return value.
C.It generates an error because CASE cannot be used with group functions.
D.It generates an error because multiple conditions cannot be specified for the WHEN clause.
答案:A
解析:这里case是用法
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值