How do I do multiple CASE WHEN conditions using SQL Server 2008?

前端 未结 10 2026
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 09:57

What I\'m trying to do is use more than one CASE WHEN condition for the same column.

Here is my code for the query:

   SELECT   Url=\'\',
                    


        
10条回答
  •  一个人的身影
    2020-11-27 10:30

    This can be an efficient way of performing different tests on a single statement

    select
    case colour_txt 
      when 'red' then 5 
      when 'green' then 4 
      when 'orange' then 3
    else 0 
    end as Pass_Flag
    

    this only works on equality comparisons!

提交回复
热议问题