IFF

functionsupportedCore SQL functions

docs.snowflake.com ↗

Conditional expression functions

Returns one of two values depending on whether a Boolean expression evaluates to true or false. This function is similar to a single-level if-then-else expression. It is similar to CASE, but only allows a single condition. You can use it to add conditional logic to SQL statements.

Syntax

IFF( <condition> , <expr1> , <expr2> )

Parameters

NameRequiredDescription
conditionrequiredThe condition is an expression that should evaluate to a BOOLEAN value (TRUE, FALSE, or NULL). If condition evaluates to TRUE, returns expr1, otherwise returns expr2.
expr1requiredA general expression. The function returns this value if the condition is true.
expr2requiredA general expression. The function returns this value if the condition is not true (that is, if it is false or NULL).

Returns

This function can return a value of any type. The function can return NULL if the value of the expression that is returned is NULL.

Usage notes

Collation details

The value returned from the function retains the collation specification of the highest-precedence collation of the expr1 and expr2 arguments.