PL/SQL Coalesce

The COALESCE function returns the first non null expression in the expression list.

COALESCE syntax

COALESCE( expr_1, expr_2, expr_n ) 

COALESCE example

 
select COALESCE(null,'1') from dual;

Result: 1


select COALESCE(null, 2) from dual;

Result: 2


select COALESCE(null, null, 3) from dual;

Result: 3


select COALESCE(null, null, null, 4) from dual;

Result: 4


select COALESCE(null, null, null, null, 5) from dual;

Result: 5


select COALESCE(null, null, 7, null, 5) from dual;

Result: 7