Reference / SQL
COALESCE()
Evaluates the arguments in order and returns the current value of the first expression that initially does not evaluate to NULL.
Syntax
COALESCE(val1, val2, ..., valN)Parameters
| Name | Type | Description |
|---|---|---|
| val1...valN | any | Expressions of compatible datatypes to test. |
Examples
Fallback phone or email
SELECT user_id, COALESCE(phone_number, backup_email, 'No contact info') AS primary_contact
FROM user_contacts;Short-circuits: arguments after the first non-null value are not evaluated.