Case When Then
用法1:
case [字段] when '字段等于相应的value' then 表达式 when '字段等于相应的value' then 表达式 else '' end
eg:select sort,qty, case qty when 1 then '少' when 2 then '中' when 3 then '多' else '未知' end as [数量范围] from test
用法2:
case when [条件] then 表达式 when [条件] then 表达式 else '' end
select sort,qty, case when qty=1 then '少' when qty=2 then '中' when qty=3 then '多' else '未知' end as [数量范围] from test