CASE equivalent of a nested IIF statement

前端 未结 4 851
暖寄归人
暖寄归人 2021-01-25 05:14

Can anyone please decode the following nested IIF to a CASE statement in SQL.. I know IIF is allowed in SQL Server 2012 but I find it hard to get an easy grasp of a nested IIF l

4条回答
  •  失恋的感觉
    2021-01-25 06:07

    I think this is what it boils down to in one CASE expression:

    CASE
      WHEN TABLE_A.Col_1 = 0 AND TABLE_A.Col_2 + (2*TABLE_A.Col_3) <= .5 THEN 'A'
      WHEN TABLE_A.Col_1 <> 0 AND TABLE_A.Col_1 <= .5 THEN 'A'
      ELSE 'B'
    END
    

提交回复
热议问题