Use the CASE expression.
Head over to this video to learn CASE expression in detail:
CASE WHEN Some_Column = 'CR' THEN 'credit'
WHEN Some_Column = 'NCR' THEN 'non-credit'
Refer to this video to understand how IFF function works:
Let’s understand how IFF function works:
We can consider IFF function as a combination of IF-ELSE and CASE statements. IFF function accepts 3 arguments which are as follows:
- Boolean expression is the first argument. This returns either true or false.
- If the result of the first expression holds ‘true’ then the 2nd argument will result as output otherwise 3rd argument.
IIF (Boolean_Expression, True_Value, Flase_Value)
SQL IFF query to compare two integers:
IIF(15 > 10, 'TRUE', 'FALSE') AS Result;
In the above example, you can observe that Condition inside IIF function (i.e., 15>10) is TRUE. So, the second argument is returned as output, which is TRUE