您的位置:首页 > 数据库

SQL的 case when语句嵌套使用

2016-05-17 14:54 351 查看


SQL的 case when语句嵌套使用

下载LOFTER

我的照片书 |

1、简单的case when语句:

case sex when ’1' then '男' when ’2’ then '女’else ’其他’ end

2、复杂的case when语句:

case when month in (01,02,03) then '第一季度' when month in (04,05,06) then '第二季度' when month in (07,08,09) then '第三季度' when month in (10,11,12) then ‘第四季度’ end

值得注意的是,语句只返回第一个符合条件的值,剩下的case部分将会被自动忽略。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: