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, ecode(coalesce(promo_end_date, promo_start_date), null, ‘ONGOING’,
promo_end_date – promo_start_date) FROM promos;



Leave a Reply 2

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


Hola

Hola

COALESCE:

The Oracle/PLSQL COALESCE function returns the first non-null expression in the list. If all expressions evaluate to null, then the COALESCE function will return null.

Parameters or Arguments

expr1, expr2, … expr_n
The expressions to test for non-null values. The expressions must all be the same datatype.

Returns

The COALESCE function returns returns any datatype such as a string, numeric, date, etc. (BUT all expressions must be the same datatype in the COALESCE function.)
If all expressions are not the same datatype, an ORA-00932 error will be returned.

Hola

Hola

A false
B True
C True
D True
E False

B,C,D