Multiple choice technology databases

If commission is null then the text “Not Applicable” must be displayed, instead of blank space. How do I write the query?

  1. select nvl(to_char(comm),'NA') from emp;

  2. select nvl(comm,'NA') from emp;

  3. select nvl(comm,NA) from emp;

  4. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The NVL function requires both parameters to have compatible data types. Since 'commission' is numeric and 'NA' is a string, we must first convert commission to character using TO_CHAR, then apply NVL. The correct syntax is nvl(to_char(comm),'NA'). Option B fails because nvl(comm,'NA') tries to substitute a string into a numeric column, and Option C has no quotes around NA.