加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

OCP-1Z0-051 第110题 AVG的使用

发布时间:2020-12-13 23:02:30 所属栏目:百科 来源:网络整理
导读:一、原题 View the Exhibit and examine the structure of the CUSTOMERS table. Using the CUSTOMERS table,you need to generate a report that shows the average credit limit for customers in WASHINGTON and NEW YORK. Which SQL statement would pro
一、原题
View the Exhibit and examine the structure of the CUSTOMERS table.

Using the CUSTOMERS table,you need to generate a report that shows the average credit limit for customers in WASHINGTON and NEW YORK.
Which SQL statement would produce the required result?
A. SELECT cust_city,AVG(cust_credit_limit)
FROM customers
WHERE cust_city IN ('WASHINGTON','NEW YORK')
GROUP BY cust_credit_limit,cust_city;

B. SELECT cust_city,'NEW YORK')
GROUP BY cust_city,cust_credit_limit;

C. SELECT cust_city,'NEW YORK')
GROUP BY cust_city;

D. SELECT cust_city,AVG(NVL(cust_credit_limit,0))
FROM customers
WHERE cust_city IN ('WASHINGTON','NEW YORK');

答案:C

二、题目翻译
查看CUSTOMERS表的结构
使用CUSTOMERS表的数据生成一个报表,显示居住在WASHINGTON和NEW YORK的客户的平均credit limit
哪条SQL语句给出所需结果?

三、题目解析
AB选项不正确,因为GROUP BY里的分组的列不对,这里应该按cust_city分组。 D选项不正确,因为要根据城市求平均值,所以需要使用GROUP BY子句分组。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读