Oracle行列转换case when then方法案例
select (select name from t_area where id=areaid) 区域, sum(case when month = '01' then money else 0 end) 一月, sum(case when month = '02' then money else 0 end) 二月, sum(case when month = '03' then money else 0 end) 三月, sum(case when month = '04' then money else 0 end) 四月, sum(case when month = '05' then money else 0 end) 五月, sum(case when month = '06' then money else 0 end) 六月, sum(case when month = '07' then money else 0 end) 七月, sum(case when month = '08' then money else 0 end) 八月, sum(case when month = '09' then money else 0 end) 九月, sum(case when month = '10' then money else 0 end) 十月, sum(case when month = '11' then money else 0 end) 十一月, sum(case when month = '12' then money else 0 end) 十二月 from t_account where year='2012' group by areaid;