IFF
functionsupportedCore SQL functionsReturns 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
| Name | Required | Description |
|---|---|---|
condition | required | The 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. |
expr1 | required | A general expression. The function returns this value if the condition is true. |
expr2 | required | A 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
- The condition can include a SELECT statement containing set operators, such as UNION, INTERSECT, and EXCEPT (MINUS). When using set operators, make sure that data types are compatible. For details, see the General usage notes in the Set operators topic.
Collation details
The value returned from the function retains the collation specification of the highest-precedence collation of the expr1 and expr2 arguments.