QuestionQ57

VerifiedUsing Conversion Functions and Conditional Expressions

Examine the structure of the PROMOS table:

Question Image

You want to create a report that displays promo names and their duration (in days). If PROMO_END_DATE has not been entered, display the message 'ONGOING'. Which queries produce the correct output?

Choose three
Explanation

Subtracting two DATE values produces a numeric number of days and returns NULL when the end date is null. TO_CHAR must convert that numeric duration to character data before COALESCE or NVL can substitute 'ONGOING'. DECODE can also return 'ONGOING' for a null duration; with a character first result, its alternate numeric result is returned as character data. NVL applied directly to the numeric duration with the character literal would require an invalid conversion, and ECODE is not a valid SQL function name.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!