All Products
Search
Document Center

MaxCompute:IF

Last Updated:Aug 02, 2023

Checks whether testCondition is true. If testCondition is true, the value of valueTrue is returned. Otherwise, the value of valueFalseOrNull is returned.

Syntax

if(<testCondition>, <valueTrue>, <valueFalseOrNull>)

Parameters

  • testCondition: required. The expression that you want to evaluate. The value is of the BOOLEAN type.

  • valueTrue: required. The value that is returned when testCondition is true.

  • valueFalseOrNull: required. The value that is returned when testCondition is false. You can set this parameter to null.

Return value

The data type of the return value is the same as the data type of valueTrue or valueFalseOrNull.

Examples

-- The return value is 200. 
select if(1=2, 100, 200); 

Related functions

For more information, see Other functions.