IIF Function - SQL


Overview


The IIF function in SQL evaluates a condition and returns one of two values, depending on whether the condition is true or false. It is similar to the IF function and is often used for conditional logic within queries.

Example:

SELECT IIF(salary >= 110000, 'High', 'Low')
FROM company.employees

Syntax:

SELECT IIF(condition, true_result, false_result)
FROM table_name

condition is the logical expression to evaluate.

true_result is the value returned if the condition is true.

false_result is the value returned if the condition is false.