我是靠谱客的博主 粗心电源,这篇文章主要介绍【SQL】case when 用法,现在分享给大家,希望可以做个参考。

语法

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 

最后

以上就是粗心电源最近收集整理的关于【SQL】case when 用法的全部内容,更多相关【SQL】case内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(106)

评论列表共有 0 条评论

立即
投稿
返回
顶部