meta data for this page
  •  

IIF()

Available in: DSQL, PSQL

Added in: 2.0

Description

IIF takes three arguments. If the first evaluates to true, the second argument is returned; otherwise the third is returned.

Result type: Depends on input.

Syntax

IIF (<condition>, ResultT, ResultF)

<condition> ::= A Boolean expression.

Example

select iif( sex = 'M', 'Sir', 'Madam' ) from Customers

IIF(Cond, Result1, Result2) is a shortcut for CASE WHEN Cond THEN Result1 ELSE Result2 END. You can also compare IIF to the ternary “? :” operator in C-like languages.