COALESCE

Click to skip syntax diagram
Read syntax diagramSkip visual syntax diagram                            .---------------.
                            V               |
>>-COALESCE--(--expression----,--expression-+--)---------------><
 

The COALESCE function returns the value of the first non-null expression.

The arguments must be compatible. Character-string arguments are compatible with datetime values. For more information about data type compatibility, see Assignments and comparisons.

expression
The arguments can be of either a built-in data type or a distinct type.41

The arguments are evaluated in the order in which they are specified, and the result of the function is the first argument that is not null. The result can be null only if all arguments can be null, and the result is null only if all arguments are null.

The selected argument is converted, if necessary, to the attributes of the result. The attributes of the result are determined by all the operands as explained in Rules for result data types.

Examples


41.
This function cannot be used as a source function when creating a user-defined function. Because it accepts any compatible data types as arguments, it is not necessary to create additional signatures to support distinct types.