语法
case when 条件 then xx
when 条件 then xx
.......
else xx
end
释义:常用在对某一字段进行分组时打标使用。
可有多个when条件,else可有可无,end一定要有
举个栗子
case when score >= 90 then '优秀'
when score >= 80 then '良好'
when score >= 60 then '及格'
else ‘不及格’
end
case when score >= 60 then '及格'
else ‘不及格’
end