IIF() Function



Syntax:

IIF(parameter, true, false)


What does it do?

The parameter in the form of a criteria string is passed, then depending on whether its true or false that value or string will be displayed.


Example:

SELECT FirstName,
IIF(FirstName = 'John', 1, 0) AS [IIF Test]
FROM Customers;


Results:

FirstName IIF Test
John 1
Jane 0
Jack 0
Jill 0

Notes: another IIF function or other functions can be nested in the true and false parameters.

HTML 5 Badge