COALESCE function in Oracle

COALESCE is an advanced function that the Oracle database supports. It is used to get the first non-null expression in the list. The COALESCE function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g and Oracle 9i.


COALESCE( expr_1, expr_2, ... expr_n )

expr_1, expr_2, … expr_n:
It is used to specify the expressions to be tested.

Example :

SELECT COALESCE( value1, value2, value3 ) result
FROM values;

Here, each value will be compared one by one by the COALESCE function for non-null values. If each value is null, the result will be NULL.

Please Share