COALESCE: Coalescing Data Values

How to:

The COALESCE operator can take 2 or more arguments. The first argument that is not NULL is returned. If all arguments are NULL, NULL is returned.


Top of page

x
Syntax: How to Coalesce Data Values
COALESCE(arg1, arg2, [ ... argn ])

where:

arg1, arg2, ..., argn

Any type

Are data values. The types of the arguments must be compatible.

This operator returns the compatible type of the arguments.



Example: Coalescing Data Values

This example,

COALESCE('A', 'B')

return A.

This example,

COALESCE(NULL, 'B')

return B.

This example,

COALESCE(NULL, NULL)

return NULL.


iWay Software