COALESCE

Purpose

This function returns the first value from the argument list which is not NULL. If all of the values are NULL, the function returns NULL.

Syntax

coalesce::=

Coalesce

Usage Notes

  • The minimum number of arguments is 2.
  • The COALESCE(expr1,expr2) function is equivalent to the CASE expression CASE WHEN expr1 IS NOT NULL THEN expr1 ELSE expr2 END.

Example

SELECT COALESCE(NULL,'abc',NULL,'xyz') COALES;