Fork me on GitHub

分组查询并统计相应状态数量

SELECT  t1,count(1) as "total",
sum(case when (status='1' and status='2') then '1' else '0' end) as "status_1",
sum(case when status='0' then '1' else '0' end) as "status_2"
FROM account WHERE 1=1 GROUP BY p1

posted @ 2019-05-31 16:54  Geek仁杰  阅读(1098)  评论(0编辑  收藏  举报