SQL Ref Msaccess



Example
SELECT IIF(500<1000, 'YES', 'NO');

Definition and Usage

The IIF() function returns a value if a condition is TRUE, or another value if a condition is FALSE.

Syntax

IIF(condition, value_if_true, value_if_false)

Parameter Values

Parameter Description
condition Required. The value to test
value_if_true Optional. The value to return if condition is TRUE
value_if_false Optional. The value to return if condition is FALSE

Technical Details

Works in: SQL Server (starting with 2012), Azure SQL Database

More Examples

Example
SELECT IIF(500<1000, 5, 10);
Example
SELECT IIF(STRCMP("hello","bye") = 0, 'YES', 'NO');
Example
SELECT OrderID, Quantity, IIF(Quantity>10, 'MORE', 'LESS')
FROM OrderDetails;