Which two SQL statements would execute successfully?

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? (Choose two.)

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? (Choose two.)

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;



Leave a Reply 5

Your email address will not be published. Required fields are marked *


Fj

Fj

Can anybody explain why these two seem different answers are both correct? Thanks.

Bina

Bina

The guideline for NVL is same kind of datatype.
A is date datatype. (correct)
B. To-date is wrong, because nvl subquery result is already a date. Don’t convert a date to date datatype.
C has date date type and ‘Ongoing’ is character datatype. (wrong)
D. To_char converted the date datatype to character and ‘Ongoing’ is also character datatype

Sayed

Sayed

B. Number data type and string
C. Number data type and string

Ritam Tiwari

Ritam Tiwari

NOTE :it is required that all the arguments in the NVL function should be of same data type.

wuxun

wuxun

B is incorrect,but not for different data type of nvl.
It’s wrong because to_date() you can’t convert “SYSDATE-END_DATE” to a date type.