case when then else end数据统计

今天用case when then else end 做了个数据统计,有一个A表,有id,status这2个字段,现在需要统计id的数目和status>5的id的数目;

用sql语句的写法:

select count(id),count(case when status>5 then 1 else null end)

from A

ok啦

posted @ 2015-08-24 22:19  trypretty  阅读(322)  评论(0编辑  收藏  举报