我想得到:
extension_id a(report_type=0) b(report_type=1)
4 0 1
5 1 1
6 2 0
求助sql语句如何写?
select extension_id,sum(report_type0) a,sum(report_type1) b from (
select extension_id
,case when report_type=1 then cnt else 0 end report_type1
,case when report_type=0 then cnt else 0 end report_type0 from(
select count(*) cnt,extension_id,report_type from eatable
group by extension_id,report_type
) a
) a group by extension_id