SQLite coalesce() Function
The SQLite coalesce()
function returns the first non-null value in the parameter list.
Syntax
Here is the syntax of the SQLite coalesce()
function:
coalesce(value1[, value2 ...])
Parameters
value1[, value2 ...]
-
Required. The parameters list. You should provide at least one parameter.
Return value
The SQLite coalesce()
function returns the first non-null value in the parameter list. This function will return NULL
if all arguments are NULL
.
If you do not provide any parameter for coalesce()
, SQLite will return an error.
Examples
This is an example to show the usages of json_group_object()
.
SELECT
coalesce(NULL, 100),
coalesce(NULL, NULL);
coalesce(NULL, 100) = 100
coalesce(NULL, NULL) =
here,
coalesce(NULL, 100)
,100
is the first non-NULL value in the parameters list, so it is returned.coalesce(NULL, NULL)
, All of the parameters areNULL
, soNULL
is returned.