OCP 11g考试题库详解:1Z0-051-105题
最新学讯:近期OCP认证正在报名中,因考试人员较多请尽快报名获取最近考试时间,报名费用请联系在线老师,甲骨文官方认证,报名从速!
我要咨询OCP 11g考试题库详解:1Z0-051-105题,完整题库请点击这里联系老师咨询了解
105. Examine the structure of the PROMOS table:
name Null Type
PROMO_ID NOT NULL NUMBER(3)
PROMO_NAME VARCHAR2(30)
PROMO_START_DATE NOT NULL DATE
PROMO_END_DATE NOT NULL DATE
You want to display the list of promo names with the message 'Same Day' for promos that started and
ended on the same day.
Which query gives the correct output?
A. SELECT promo_name, NVL(NULLIF(promo_start_date, promo_end_date), 'Same Day') FROM promos;
B. SELECT promo_name, NVL(TRUNC(promo_end_date - promo_start_date), 'Same Day') FROM promos;
C. SELECT promo_name, NVL2(TO_CHAR(TRUNC(promo_end_date-promo_start_date)), NULL,'SameDay') FROM promos;
D. SELECT promo_name, DECODE((NULLIF(promo_start_date, promo_end_date)), NULL,'Same day') FROM promos;
Answer: D
试题解析:
A。NULLIF里面额数据类型为date与 'Same Day'字符串类型不匹配,错误。
B。TRUNC将小数部分截断,但类型不一致,错误。
C。TO_CHAR(TRUNC(promo_end_date-promo_end_date)),如果相等,TRUNC为0,to_char后,字符为0,即始终有值,NVL2返回第二个值,即NULL