语法
复制代码
1
2
3
4
5
6case when 条件 then xx when 条件 then xx ....... else xx end
释义:常用在对某一字段进行分组时打标使用。
可有多个when条件,else可有可无,end一定要有
举个栗子
复制代码
1
2
3
4
5
6case when score >= 90 then '优秀' when score >= 80 then '良好' when score >= 60 then '及格' else ‘不及格’ end
复制代码
1
2
3
4case when score >= 60 then '及格' else ‘不及格’ end
最后
以上就是粗心电源最近收集整理的关于【SQL】case when 用法的全部内容,更多相关【SQL】case内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复