半城风月半城雪
2018-04-09 03:16
采纳率: 50%
浏览 2.7k

请问oracle多列转多行

请问大家本来是这样
图片说明
要转成
图片说明
但是只有一行,怎么把五列都转出来
现在是这样写的
SUM(CASE WHEN xxx='000' THEN eee ELSE null END) as "WWW"
但其实就不用sum,都是查好的,就是要转成竖的,
不知道怎么弄了
换了一个方法,但是报错,麻烦帮忙看下

 select * from(
 select t.jidi,r.caishou as xx from
(select f.FNETWEIGHT as caishou,g.FBASEADDRESSID from T_CUS_CollectingstatisticsE f,T_CUS_Collectingstatistics g where f.FPARENTID = g.fid 
and to_char(f.FPICKYTIME,'yyyy-mm-dd') like '2017%') r  left join
(select a.fid,a.FNUMBER,a.FDISPLAYNAME_L2  as jidi from T_BD_GeneralAsstActTypeGroup b,T_BD_GeneralAsstActType a where  b.FNUMBER='NSB001' and a.FGROUPID = b.FID)t on t.fid = r.FBASEADDRESSID) pivot (sum(xx) for jidi in (''aa'),aa,'bb',bb);
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

5条回答 默认 最新

相关推荐 更多相似问题