title: "COALESCE function" description: "Returns the first non-NULL element provided." menu: main:
parent: 'sql-functions'
COALESCE
returns the first non-NULL
element provided.
Parameter | Type | Description |
---|---|---|
val | Any | The values you want to check. |
All elements of the parameters for coalesce
must be of the same type; coalesce
returns that type, or NULL.
SELECT coalesce(NULL, 3, 2, 1) AS coalesce_res;
res
-----
3