Previous Topic

Next Topic

Coalesce - SQL Function

Coalesce(Expr1: Variant[, Expr2: Variant[, ... ExprN: Variant]]): Variant

Coalesce Returns the first non-NULL value from a list of expressions. If all values in the list are NULL, returns NULL.

All expressions must have the same data type. You can use the CAST function to ensure all expressions have the same data type.

Coalesce function syntax has these named arguments:

Parameter

Description

Expr1

Required. The first expression to be evaluated as non-NULL.

Expr2...ExprN

Optional. A list of expressions to be evaluated as non-NULL.

In the following example, if the BankReference field contains a NULL value, then the field value returned will be the BankParticulars field. If the BankParticulars field also contains a NULL, then the literal string 'No Bank' will be returned:

SELECT CustomerCode,

  Coalesce(BankReference,BankParticulars,'No Bank') AS Bank

FROM ARCUST

See Also

SQL Case Functions

Book Contents

Book Index