zoukankan      html  css  js  c++  java
  • OCP-1Z0-051-V9.02-102题

    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)  已经是number类型,不需要转换

    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)  已经是number类型,不需要转换

    FROM transactions

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

    Answer: B

    答案解析:

    A,TO_DATE(trans_date,'hh24'),trans_date已经为日期类型,不用再to_date


    scott@TESTDB> select to_date(HIREDATE,'yy24') from emp;
    select to_date(HIREDATE,'yy24') from emp
                            *
    ERROR at line 1:
    ORA-01821: date format not recognized

    B,正确,这里0隐式转换为字符型

    C,(TO_NUMBER(trans_amt,'$99999999.99'),trans_amt已经是数值型,不用再to_number

    D,错误同C一样。


  • 相关阅读:
    盘点杂谈(二)
    物料中库存的管理(一)
    物料中的库存管理(二)
    MM中的MRP(一)
    (转)成功ERP需实施顾问和项目经理亲密协作
    好久不来.
    MM中的MRP(三)
    MM中的MRP(二)
    深度学习浅层理解(一)
    处理流小结
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13316875.html
Copyright © 2011-2022 走看看