Best way to do nested case statement logic in SQL Server

前端 未结 9 1381
误落风尘
误落风尘 2020-11-29 15:23

I\'m writing an SQL Query, where a few of the columns returned need to be calculated depending on quite a lot of conditions.

I\'m currently using nested case stateme

9条回答
  •  情歌与酒
    2020-11-29 15:48

    You can combine multiple conditions to avoid the situation:

    CASE WHEN condition1 = true AND condition2 = true THEN calculation1 
         WHEN condition1 = true AND condition2 = false 
         ELSE 'what so ever' END,
    

提交回复
热议问题