Which queries give the correct output?

Examine the structure of the PROMOS table:
You want to generate a report showing promo names and their duration (number of days).
If the PROMO_END_DATE has not been entered, the message ‘ONGOING’ should be displayed.
Which queries give the correct output? (Choose all that apply.)

Examine the structure of the PROMOS table:
You want to generate a report showing promo names and their duration (number of days).
If the PROMO_END_DATE has not been entered, the message ‘ONGOING’ should be displayed.
Which queries give the correct output? (Choose all that apply.)

A.
SELECT promo_name, TO_CHAR(NVL(promo_end_date -promo_start_date,’ONGOING’)) FROM
promos;

B.
SELECT promo_name,COALESCE(TO_CHAR(promo_end_date – promo_start_date),’ONGOING’)
FROM promos;

C.
SELECT promo_name, NVL(TO_CHAR(promo_end_date -promo_start_date),’ONGOING’) FROM
promos;

D.
SELECT promo_name, DECODE(promo_end_date
-promo_start_date,NULL,’ONGOING’,promo_end_date – promo_start_date) FROM promos;

E.
SELECT promo_name, decode(coalesce(promo_end_date,promo_start_date),null,’ONGOING’,
promo_end_date – promo_start_date)
FROM promos;



Leave a Reply 3

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


Zulal

Zulal

I think in “D”, the expression promo_end_date-promo_start_date could give error if promo_end_date is null.Because null-(something) gives error.

Zulal

Zulal

Sorry my fault.Null-(something) gives null. But , null – date gives error.

Andrzej

Andrzej

“D” give error ORA-00932.