【查询】Case
测试数据

用法一: 等值判断(当于switch case )

Select S#, C#, C#= ( case C# when 1 then '语文' when 2 then '数学' when 3 then '英语' when 4 then '思修' end ) from sc
用法二: 条件判断(相当于if else if else)

Select S#, score, score= ( case when score<60 then '差' when score between 60 and 80 then '中' when score between 80 and 90 then '良' when score between 90 and 100 then '优' else '缺考' end ) from sc

浙公网安备 33010602011771号