COALESCE Function

Returns the first non-null or nonmissing value from a list of numeric arguments.

Category: Mathematical
Returned data type: DOUBLE

Syntax

COALESCE(expression[, ...expression])

Arguments

expression

specifies any valid expression that evaluates to a numeric value.

Data type DOUBLE
See <sql-expression>
FedSQL Expressions.

Details

COALESCE accepts one or more numeric expressions. The COALESCE function checks the value of each expression in the order in which they are listed and returns the first non-null or nonmissing value. If only one value is listed, then the COALESCE function returns the value of that argument. If all the values of all expressions are null or missing, then the COALESCE function returns a null or a missing value depending on whether you are in ANSI mode or SAS mode. For more information, see How FedSQL Processes Nulls and SAS Missing Values.

Comparisons

The COALESCE function searches numeric expressions, whereas the COALESCEC function searches character expressions.

Example

The following statement illustrates the COALESCE function:
Statements
Results
select COALESCE(., .A, 33, 22, 44, .);
33

See Also

Functions:
Last updated: February 23, 2017