OCP-1Z0-051-V9.02-111题

111. View the Exhibit and examine the structure of the CUSTOMERS table.

Which statement would display the highest credit limit available in each income level in each city in   the

CUSTOMERS table? 

 

A. SELECT cust_city, cust_income_level, MAX(cust_credit_limit )

FROM customers

GROUP BY cust_city, cust_income_level, cust_credit_limit;

B. SELECT cust_city, cust_income_level, MAX(cust_credit_limit)

FROM customers

GROUP BY cust_city, cust_income_level; 分组先按照city再按照income level

C. SELECT cust_city, cust_income_level, MAX(cust_credit_limit)

FROM customers

GROUP BY cust_credit_limit, cust_income_level, cust_city ;  顺序错了

D. SELECT cust_city, cust_income_level, MAX(cust_credit_limit)

FROM customers

GROUP BY cust_city, cust_income_level, MAX(cust_credit_limit);

Answer: B
答案解析:
按照题意,先按照每个城市后按照每个城市中的收入水平来分组查看最高的credit limit
故在group by时应为 group by cust_city, cust_income_level;
A答案,没有涉及到 cust_credit_limit的分组。
 
B答案与题意相符,正确,数据太多,取前5行。
 
sh@TEST0924> SELECT cust_city, cust_income_level, MAX(cust_credit_limit)
  2   FROM customers where rownum<=5
  3  GROUP BY cust_city, cust_income_level;
 
CUST_CITY                      CUST_INCOME_LEVEL              MAX(CUST_CREDIT_LIMIT)
------------------------------ ------------------------------ ----------------------
Joinville                      G: 130,000 - 149,999                             9000
Ede                            G: 130,000 - 149,999                             1500
Schimmert                      G: 130,000 - 149,999                            11000
Scheveningen                   G: 130,000 - 149,999                             1500
Hoofddorp                      G: 130,000 - 149,999                             7000
 
 
C答案,没有涉及cust_credit_limit分组,且 cust_income_level, cust_city 顺序错了,应为group by cust_city, cust_income_level;
 
D答案,语法错误
sh@TEST0924> SELECT cust_city, cust_income_level, MAX(cust_credit_limit)
  2  FROM customers
  3  GROUP BY cust_city, cust_income_level, MAX(cust_credit_limit);
GROUP BY cust_city, cust_income_level, MAX(cust_credit_limit)
                                       *
ERROR at line 3:
ORA-00934: group function is not allowed here

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值