94.Examine the structure of the PROGRAMS table:

  • Post author:
  • Post category:其他


94.Examine the structure of the PROGRAMS table:

name Null Type

—— ——— ——-

PROG_ID NOT NULL NUMBER(3)

PROG_COST NUMBER(8,2)

START_DATE NOT NULL DATE

END_DATE DATE

Which two SQL statements would execute successfully?

A.SELECT NVL(ADD_MONTHS(END_DATE,1),SYSDATE) FROM programs;

B.SELECT TO_DATE(NVL(SYSDATE-END_DATE,SYSDATE)) FROM programs;

C.SELECT NVL(MONTHS_BETWEEN(start_date,end_date),’Ongoing’) FROM programs;

D.SELECT NVL(TO_CHAR(MONTHS_BETWEEN(start_date,end_date)),’Ongoing’) FROM programs;

答案:AD

A:正确,ADD_MONTHS(END_DATE,1)的结果于SYSDATE类型相同

B:错误,SYSDATE-END_DATE结果为数字(具体相差的天数)于SYSDATE类型不符合

C:错误,MONTHS_BETWEEN(start_date,end_date)类型为number,’Ongoing’无法转化为number,这里如果改成可以

转化成number类型的值也可以,比如’123’什么的

D:正确to_char转化后与’Ongoing’类型一致



版权声明:本文为dwj19830118原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。