COALESCE function in Amazon QLDB
Important
End of support notice: Existing customers will be able to use Amazon QLDB until end of support on 07/31/2025. For more details, see
Migrate an Amazon QLDB Ledger to Amazon Aurora PostgreSQL
In Amazon QLDB, given a list of one or more arguments, use the COALESCE
function to evaluate the arguments in order from left to right and return the first
value that is not an unknown type (NULL
or MISSING
). If all
argument types are unknown, the result is NULL
.
The COALESCE
function doesn't propagate NULL
and
MISSING
.
Syntax
COALESCE (
expression
[,expression
, ... ] )
Arguments
expression
-
The list of one or more field names or expressions that the function evaluates. Each argument can be any of the supported Data types.
Return type
Any supported data type. The return type is either NULL
or the same
as the type of the first expression that evaluates to a non-null and non-missing
value.
Examples
SELECT COALESCE(1, null) FROM << 0 >> -- 1 SELECT COALESCE(null, null, 1) FROM << 0 >> -- 1 SELECT COALESCE(null, 'string') FROM << 0 >> -- "string"