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’类型一致