coalesce() function

Returns the first non-NULL value from the expression list.
This function can take any number of arguments.

Syntax

coalesce(expression1, expression2 ...)

Arguments

expression - any valid expression or value, irregardless of type.

Example

coalesce(NULL, 2) → 2
coalesce(NULL, 2, 3) → 2
coalesce(7, NULL, 3*2) → 7

coalesce("fieldA", "fallbackField", 'ERROR') → value of fieldA if it is non-NULL else the value of "fallbackField" or the string 'ERROR' if both are NULL