Oracle 数据行列转换

  • A+
所属分类:Oracle

Oracle 数据行列转换

SQL语句

 SELECT sfznum, sum(sb_dwjn) 社保单位缴纳, sum(sb_grjn) 社保个人缴纳,sum(gjj_grjn) 公积金单位缴纳,sum(gjj_grjn) 公积金个人缴纳
 FROM (SELECT sfznum,categ_group,  
        DECODE(categ_group, '社保', dwjn,'') sb_dwjn,  
        DECODE(categ_group, '社保', grjn,'') sb_grjn,
        DECODE(categ_group, '公积金', dwjn,'') gjj_dwjn,  
        DECODE(categ_group, '公积金', grjn,'') gjj_grjn  
     FROM receiv)  
 GROUP BY sfznum; 
钰玺

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: