The COALESCE and NVL expressions return the first non-NULL value
from a series of value expressions.
SQL evaluates each value expression in a COALESCE or NVL
expression until it can return a non-NULL value. If all the
columns specified in the COALESCE or NVL expression contain NULL
values, then NULL is returned.
The data type of the resulting expression is a common data type
to which all value expressions in the list can be converted.
For example, COALESCE(SALARY_AMOUNT, ESTIMATED_BONUS, 1.23E+5)
results in a DOUBLE PRECISION result because at least one
argument is a floating point value.
The following example replaces the stored NULL value in the
MIDDLE_INITIAL column of the EMPLOYEES table with a hyphen:
SQL> SELECT FIRST_NAME, LAST_NAME, MIDDLE_INITIAL,
cont> COALESCE(MIDDLE_INITIAL, '-')
cont> FROM EMPLOYEES
cont> WHERE LAST_NAME LIKE 'L%';
FIRST_NAME LAST_NAME MIDDLE_INITIAL
Jo Ann Lapointe C C
Hope Lapointe NULL -
Stan Lasch P P
Norman Lasch NULL -
Peter Lengyel A A
Peter Lonergan V V
6 rows selected