ISNULL

The ISNULL function returns the first value in the specified expressions that is not NULL; otherwise, it returns NULL. ISNULL is equivalent to the COALESCE function except that it takes only two arguments.

Syntax

ISNULL (expression1, expression2)

Remarks

ISNULL (expression1, expression2) is equivalent to this CASE statement:

CASE WHEN expression1 IS NOT NULL THEN expression1
	WHEN expression2 IS NOT NULL THEN expression2
	ELSE NULL END

The following table lists the data types of the input arguments for ISNULL.

Data Type of expression

Output Type

BINARY, DATE, DECIMAL, FLOAT, INTEGER, INTERVAL_YEAR, INTERVAL_DAY, NULL, STRING, TIME, TIMESTAMP, XML

Follows the ANSI SQL rules for data type precedence.

Example

SELECT ProductID, ISNULL (SalePrice, UnitPrice) “Best Price”
FROM /shared/examples/ds_orders/products products