IIF Command is available in SQL Server 2012 and later versions. All It does is return one of two values, depending on the Boolean expression. You can do the same thing with CASE command, but IIF is simpler for sure.
IIF (Your Boolean Expression, True value, False Value)
True value is the value you want to return if Boolean expression is true
False value is the value you want to return if Boolean expression is false.
CHOOSE Command
Choose command is available in SQL Server 2012 and later versions. It is very simple function just like IIF. It returns the item at the specified index from a list of values.
CHOOSE (Index, value1,value2, ....)
Here is an another example using a table.
Let's try to display which season product became available.

No comments:
Post a Comment