IIF function can be nested in SQL Server 2012. We can replace IF..ElseIF.... kind of operation in T-SQL with Single SELECT statement by using IIF( condition, IIF( Condition, IIF ( condition, ... , ...)))
Sample: DECLARE @Percentage AS NUMERIC(5,2) = 75
SELECT IIF(@Percentage >= 75, 'Distinction',
IIF(@Percentage>=60 AND @Percentage<75, 'First Pass',
IIF(@Percentage>=50 AND @Percentage<65, 'Second Pass',
IIF(@Percentage>=35 AND @Percentage<50, 'Third Pass', 'Fail'))))
Output
Distinction
NOTE: The nesting level of IIF fucntion is up to
10