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部分将会被自动忽略。