OCP-1Z0-051 第69题 ORDER BY 的null值排序

一、原题
You need to generate a list of all customer last names with their credit limits from the CUSTOMERS table. Those customers who do not have a credit limit should appear last in the list.
Which two queries would achieve the required result? (Choose two.)
A. SELECT cust_last_name, cust_credit_limit
       FROM customers
ORDER BY cust_credit_limit DESC ;

B. SELECT cust_last_name, cust_credit_limit
        FROM customers
ORDER BY cust_credit_limit;

C. SELECT cust_last_name, cust_credit_limit
        FROM customers
ORDER BY cust_credit_limit NULLS LAST;

D. SELECT cust_last_name, cust_credit_limit
        FROM customers
ORDER BY cust_last_name, cust_credit_limit NULLS LAST;

答案:BC
二、题目翻译
要根据CUSTOMERS表生成一个列表,显示客户的last name和他们的credit limits,那些没有credit limit的客户显示到列表的后面。(即null值放在最后)
哪两个查询能获取所需结果(选择两个正确的选项)
三、题目解析
A选项不正确,因为默认情况下,cust_credit_limit DESC降序排列后,空值会排列到前面。
B选项正确,默认升续排列,空值会排列到后面。
C选项正确,NULLS LAST关键字可以把空值排列到后面。
D选项不正确,因为排序条件不正确,先按名字排序了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值