Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Evaluates the arguments in order and returns the value of the first expression that initially does not evaluate to NULL.
Syntax
COALESCE ( expression1, expression2, [ ,…n ] )
Arguments
expression
An expression of any type.
Return Types
The type of the first non-null expression.
Examples
SELECT COALESCE(a, b) AS result FROM input
Expression | Result |
---|---|
COALESCE(0, ‘a’) | 0 |
COALESCE(NULL, ‘a’) | ‘a’ |
COALESCE(NULL, NULL) | null |
COALESCE(NULL, NULL, 2, NULL) | 2 |