COALESCE function - Amazon Quantum Ledger Database (Amazon QLDB)

COALESCE function

Given a list of one or more arguments, evaluates the arguments in order from left to right and returns 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"

Related functions