1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
select A.years,A.SUM2015,B.SUM2014 from ( select * from ( select sum (decode(to_char(rdate, 'mm' ), '01' ,nums,0)) nums01, sum (decode(to_char(rdate, 'mm' ), '02' ,nums,0)) nums02, sum (decode(to_char(rdate, 'mm' ), '03' ,nums,0)) nums03, sum (decode(to_char(rdate, 'mm' ), '04' ,nums,0)) nums04, sum (decode(to_char(rdate, 'mm' ), '05' ,nums,0)) nums05, sum (decode(to_char(rdate, 'mm' ), '06' ,nums,0)) nums06, sum (decode(to_char(rdate, 'mm' ), '07' ,nums,0)) nums07, sum (decode(to_char(rdate, 'mm' ), '08' ,nums,0)) nums08, sum (decode(to_char(rdate, 'mm' ), '09' ,nums,0)) nums09, sum (decode(to_char(rdate, 'mm' ), '10' ,nums,0)) nums10, sum (decode(to_char(rdate, 'mm' ), '11' ,nums,0)) nums11, sum (decode(to_char(rdate, 'mm' ), '12' ,nums,0)) nums12 from personsituation where to_char(rdate, 'yyyy' )= '2015' ) unpivot (sum2015 for years in (nums01,nums02,nums03,nums04,nums05,nums06,nums07,nums08,nums09,nums10,nums11,nums12) )) A left join ( select * from ( select sum (decode(to_char(rdate, 'mm' ), '01' ,nums,0)) nums01, sum (decode(to_char(rdate, 'mm' ), '02' ,nums,0)) nums02, sum (decode(to_char(rdate, 'mm' ), '03' ,nums,0)) nums03, sum (decode(to_char(rdate, 'mm' ), '04' ,nums,0)) nums04, sum (decode(to_char(rdate, 'mm' ), '05' ,nums,0)) nums05, sum (decode(to_char(rdate, 'mm' ), '06' ,nums,0)) nums06, sum (decode(to_char(rdate, 'mm' ), '07' ,nums,0)) nums07, sum (decode(to_char(rdate, 'mm' ), '08' ,nums,0)) nums08, sum (decode(to_char(rdate, 'mm' ), '09' ,nums,0)) nums09, sum (decode(to_char(rdate, 'mm' ), '10' ,nums,0)) nums10, sum (decode(to_char(rdate, 'mm' ), '11' ,nums,0)) nums11, sum (decode(to_char(rdate, 'mm' ), '12' ,nums,0)) nums12 from personsituation where to_char(rdate, 'yyyy' )= '2014' ) unpivot (sum2014 for years in (nums01,nums02,nums03,nums04,nums05,nums06,nums07,nums08,nums09,nums10,nums11,nums12) )) B on A.years = B.years |