MySQL case...when...使用案例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
select account_id as "账号", 
case account_status
when 1 then "有效"
when 0 then "无效"
end as "有效?",
case task_status
when 0 then "等待初始化"
when 1 then "初始化中"
when 2 then "初始化失败"
when 3 then "初始化成功"
end as "任务状态",
from_unixtime(crawled_latest_article_post_time, "%Y-%m-%d %H:%i:%s") as "最近文章发布时间"
from sogou_weixin_account_init_task
where account_level <= 4
order by account_status desc, crawled_latest_article_post_time desc
;