OCP-1Z0-051 第99题 AVG函数
2014-05-09 19:54
218 查看
一、原题
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
二、题目翻译
下面是PROMOTIONS表的结构:
使用PROMOTIONS表,你需要找出category A中在$0-2000范围和$2000-5000范围内的所有promos的平均成本(cost).
执行下面的SQL语句:
结果是什么?
A.执行成功,并得出所需结果。
B.报错,因为NULL不能作为一个返回值被指定。
C.报错,因为CASE不能用在组函数中。
D.报错,因为WHEN子句不能指定多个条件。
三、题目解析
NULL值在avg函数中不会计算,所以计算平均值时会忽略null值,例如:返回4行,有1行为空,则平均值就是总数/3。
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
二、题目翻译
下面是PROMOTIONS表的结构:
使用PROMOTIONS表,你需要找出category A中在$0-2000范围和$2000-5000范围内的所有promos的平均成本(cost).
执行下面的SQL语句:
结果是什么?
A.执行成功,并得出所需结果。
B.报错,因为NULL不能作为一个返回值被指定。
C.报错,因为CASE不能用在组函数中。
D.报错,因为WHEN子句不能指定多个条件。
三、题目解析
NULL值在avg函数中不会计算,所以计算平均值时会忽略null值,例如:返回4行,有1行为空,则平均值就是总数/3。
相关文章推荐
- OCP 1Z0 051 QUESTION NO: 61
- OCP-1Z0-051 补充题库 第12题 oracle函数分类
- OCP-1Z0-051 补充题库 第24题 SYNONYM同义词
- OCP-1Z0-051-题目解析-第11题
- OCP-1Z0-051-题目解析-第7题
- OCP-1Z0-051-题目解析-第22题
- OCP-1Z0-051-题目解析-第35题
- OCP-1Z0-051-题目解析-第48题
- OCP-1Z0-051-2015-5题
- OCP-1Z0-051-2015-40题
- OCP-1Z0-051-2015-54题
- OCP-1Z0-051-题目解析-第31题
- OCP-1Z0-051-题目解析-第11题
- OCP-1Z0-051-V9.02-11题
- OCP-1Z0-051-V9.02-58题
- OCP-1Z0-051-V9.02-30题
- OCP-1Z0-051-V9.02-52题
- OCP-1Z0-051-V9.02-62题
- OCP-1Z0-051-V9.02-79题
- OCP-1Z0-051-V9.02-92题