Skip to main content

IIF

Returns one of two values, depending on whether the Boolean expression evaluates to true or false.

Syntax​

IIF ( boolean_expression, true_value, false_value [ , else_value ] ) 

Arguments​

boolean_expression
A valid Boolean expression.

If this argument is not a Boolean expression then a syntax error is raised.

true_value
Value to return if boolean_expression evaluates to true.

false_value
Value to return if boolean_expression evaluates to false.

else_value
Value to return if boolean_expression doesn't evaluate to true or false.

Return Type​

Returns the type value returned.

Examples​

Examples in this section use the example blockchain.

The following example returns "yes" if b is true, "no" if b is false, and "else" otherwise.

SELECT IIF(b,"yes","no","else")  FROM example;

Response:

IIF(b,"yes","no","else")  [STRING]
else
no
yes
no