两种实现多条件判断的case when 方法
// An highlighted block
select (case when 条件 and 条件 then 0 when 条件 and 条件 then 1 else 2 end) as name from table
select count = (case when 条件 and 条件 then 0 when 条件 and 条件 then 1 else 2 end) from table
SQLServer2005 CASE WHEN的两种用法
第一种:普通的CASE 函数
case sex
when ‘1’ then ‘数字1’
when ‘2’ then ‘数字2’
else ‘不是1也不是2’
end as num
第二种:CASE 搜索函数
case
when sex=‘1’ then ‘数字1’
when sex=‘2’ then ‘数字2’
else ‘不是1也不是2’
end as num