NULLIF

The NULLIF function compares two arguments and returns NULL if they are equal; otherwise, it returns the first argument.

Syntax

NULLIF (expression1, expression2)

Remarks

The first argument in NULLIF cannot be NULL. The output data type of NULLIF is always the same as the first argument.
The function NULLIF (expression1, expression2) is equivalent to:
CASE
WHEN expression1 = expression2 THEN NULL
ELSE expression1
END
The data types of the two input arguments must be of comparable types. The output argument data type is the same as expression1.

Example

SELECT ProductID, UnitPrice, NULLIF (UnitPrice, 0) as "Null Price"
FROM /shared/examples/ds_orders/products products