To apply Nested-IF in SQL Server, you can use the Case
statement instead of Multiple-If as below:
SELECT CASE
WHEN Active= 'N' or Available = 'Y'
THEN 1
ELSE 0
END as Instore, * FROM Store
Use CAST if you want the result as a Boolean value.
SELECT CAST(
CASE
WHEN Active= 'N' or Available = 'Y'
THEN 1
ELSE 0
END AS bit) as Instore, * FROM Store
Nested-IF-Else in SQL Server Example
SELECT
CASE
WHEN value <= 0 THEN 0
WHEN value >= 100 THEN 1
WHEN value >= 1000 THEN 2
WHEN value >= 10000 THEN 3
END as aresult
FROM Data ;
You can see also