NULLIF

Updated at:

Compares the values of expr1 and expr2. If the values are the same, null is returned. If the values are not the same, the value of expr1 is returned.

Syntax

T nullif(T <expr1>, T <expr2>)

Parameters

expr1 and expr2: required. Expressions of any data type. T specifies the type of input data. The type can be any data type supported by MaxCompute.

Return value

The value of expr1 or null is returned.

Examples

-- The return value is 2. 
select nullif(2, 3);
-- The return value is null. 
select nullif(2, 2);
-- The return value is 3. 
select nullif(3, null);

Related functions

For more information, see Overview of other functions.