coalesce
Descriptionβ
Returns the first non-NULL expression among the input parameters. Returns NULL if non-NULL expressions cannot be found.
Syntaxβ
coalesce(expr1,...);
Parametersβ
expr1
: the input expressions, which must evaluate to compatible data types. The supported data types are BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, DATETIME, DATE, DECIMALV2, DECIMAL32, DECIMAL64, DECIMAL128, VARCHAR, BITMAP, PERCENTILE, HLL, and TIME.
Return valueβ
The return value has the same type as expr1
.
Examplesβ
mysql> select coalesce(3,NULL,1,1);
+-------------------------+
| coalesce(3, NULL, 1, 1) |
+-------------------------+
| 3 |
+-------------------------+
1 row in set (0.00 sec)