日期:2014-05-17 浏览次数:20696 次
select nd,yf,bumen, sum(case when xiaoshou_dm = 'a' then shuliang else 0) end dm_a, sum(case when xiaoshou_dm = 'b' then shuliang else 0) end dm_b, sum(case when xiaoshou_dm = 'c' then shuliang else 0) end dm_c, sum(case when xiaoshou_dm = 'd' then shuliang else 0) end dm_d, sum(case when xiaoshou_dm = 'e' then shuliang else 0) end dm_e, from t group by nd,yf,bumen
------解决方案--------------------
典型行列转换,使用decode,case函数都是可以的
------解决方案--------------------
可以自己写个通用的function