ITPub博客

首页 > 数据库 > Oracle > OCP 1Z0-051-97

OCP 1Z0-051-97

原创 Oracle 作者:LuiseDalian 时间:2014-05-19 07:02:36 0 删除 编辑
(97)View the Exhibit and evaluate the structure and data in the CUST_STATUS table. You issue the following SQL statement:

SELECT custno, NVL2(NULLIF(amt_spent, credit_limit), 0, 1000) "BONUS" FROM cust_status;

Which statement is true regarding the execution of the above query?
 
 
 
A. It produces an error because the AMT_SPENT column contains a null value.

B. It displays a bonus of 1000 for all customers whose AMT_SPENT is less than CREDIT_LIMIT.

C. It displays a bonus of 1000 for all customers whose AMT_SPENT equals CREDIT_LIMIT,  or AMT_SPENT is null .

D. It produces an error because the TO_NUMBER function must be used to convert the result of the NULLIF function before it can be used by the NVL2 function.

答案:(C)

解析:只是说NULLIF的第一个参数不能指定为NULL字面量,但来自列中的NULL是可以接受的。

CREATE TABLE cust_status

(

  CustNo      NUMBER(2) NOT NULL,

  AmtSpent    NUMBER(10, 2),

  CreditLimit NUMBER(10, 2)

);

INSERT INTO cust_status VALUES(1, 1000, 1000);

INSERT INTO cust_status VALUES(2, 2000, 2500);

INSERT INTO cust_status VALUES(3, NULL, 3000);

INSERT INTO cust_status VALUES(4, 3000, 2800);

SELECT custno, NVL2(NULLIF(amtspent, creditlimit), 0, 1000) "BONUS" FROM cust_status;


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/17013648/viewspace-1163933/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: OCP 1Z0-051-99
下一篇: OCP 1Z0-051-92
请登录后发表评论 登录
全部评论

注册时间:2012-02-06

  • 博文量
    1986
  • 访问量
    6043426