IF function is a simplified alternative to the CASE expression for handling conditional logic.
Syntax
Parameters
| Parameter | Description | Supported input types |
|---|---|---|
<condition> | Condition that the function evaluates. | BOOLEAN |
<then> | Value returned when <condition> evaluates to true. | Any |
<else> | Value returned when <condition> evaluates to false or NULL. Must match the data type of <then>. | Any |
Return type
TheIF function returns the same data type as the <then> and <else> parameters.
Example
The following example uses theIF function to determine if the current day is a weekend or weekday:
Weekendwhen the current day is Saturday or Sunday.Weekdayfor any other day.