COALESCE

=COALESCE Function =



Expression:
COALESCE(expression 1, expression 2, expression n)

Description of the COALESCE function:
 An COALESCE function is an extension of the NVL funtion but it can take mulitple values. The world "COALESCE" means to "come together". 

Explanation:
T he coalesce function returns the first non-null expression in the list. If all expressions evaluate to null, then the coalesce function will return null.

COALESCE Function Example:
SELECT COALESCE (last_name, first_name, 'No name') AS "Names" FROM employees
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">**<span style="font-family: Georgia, serif;">Names ** ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">Abel ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">Davies ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">De Haan ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">Ernst ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">Fay ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">Gietz ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">Grant ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">Hartstein ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">Higgins ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">Hunold ||

<span style="color: #000000; font-family: 'Courier New', Courier, monospace;"><span style="color: #0000ff; font-family: Georgia, serif;">SELECT COALESCE (Null, Null, 'I am Not a Null', Null) as "NotNull" FROM dual
 * <span style="font-family: 'Courier New', Courier, monospace;">**<span style="font-family: 'Courier New', Courier, monospace;">NotNull ** ||
 * <span style="font-family: 'Courier New', Courier, monospace;">I am Not a Null ||

<span style="color: #000000; font-family: 'Courier New', Courier, monospace;"><span style="color: #0000ff; font-family: 'Courier New', Courier, monospace;">SELECT COALESCE(NULL, '2', '5') AS "Examples" FROM dual
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">**<span style="font-family: Georgia, serif;">Example ** ||
 * <span style="color: #000000; font-family: 'Courier New', Courier, monospace;">2 ||