整理出来的数据如图一,然后想要达到图二的结果,sql该怎么写!!求助大佬
select city, sum(case when 分类='分类01' then 数量 else 0 end) "分类01", sum(case when 分类='分类02' then 数量 else 0 end) "分类02", sum(case when 分类='分类03' then 数量 else 0 end) "分类03" from 表 group by city
select 分类,city,sum(数量) from 表 group by 分类,city ,,然后在帆软里面合计用公式写就好了,,分类横向拓展,,city纵向拓展