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.
Syntax:
COALESCE( expr_1, expr_2, ... expr_n )
Parameters:
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; |
Explanation:
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.