ITPub博客

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

OCP 1Z0-051-102

原创 Oracle 作者:LuiseDalian 时间:2014-05-20 07:15:19 0 删除 编辑
(102)Examine the structure of the TRANSACTIONS table:

name                            Null             Type

TRANS_ID                    NOT NULL   NUMBER(3)

CUST_NAME                                    VARCHAR2(30)

TRANS_DATE                                  TIMESTAMP

TRANS_AMT                                    NUMBER(10,2)

You want to display the date, time, and transaction amount of transactions that where done before 12 noon.

The value zero should be displayed for transactions where the transaction amount has not been entered.

Which query gives the required result?

A.

SELECT TO_CHAR(trans_date,'dd-mon-yyyy hh24:mi:ss'), TO_CHAR(trans_amt,'$99999999D99')

FROM transactions

WHERE TO_NUMBER(TO_DATE(trans_date,'hh24')) < 12 AND COALESCE(trans_amt, NULL)<>NULL;

B.

SELECT TO_CHAR(trans_date,'dd-mon-yyyy hh24:mi:ss'), NVL(TO_CHAR(trans_amt,'$99999999D99'),0)

FROM transactions

WHERE TO_CHAR(trans_date,'hh24') < 12;

C.

SELECT TO_CHAR(trans_date,'dd-mon-yyyy hh24:mi:ss'), COALESCE(TO_NUMBER(trans_amt,'$99999999.99'),0)

FROM transactions

WHERE TO_DATE(trans_date,'hh24') < 12;

D.

SELECT TO_DATE (trans_date,'dd-mon-yyyy hh24:mi:ss'), NVL2(trans_amt,TO_NUMBER(trans_amt,'$99999999.99'), 0)

FROM transactions

WHERE TO_DATE(trans_date,'hh24') < 12;


答案:(B)

解析:

A(X),<>NULL就错了

C(X),D(X),不应该调用TO_NUMBER()函数


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

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

注册时间:2012-02-06

  • 博文量
    1986
  • 访问量
    6040893