日期:2014-05-17 浏览次数:20720 次
with tt as( select 1 id, 1 seq, 'T1' type, 1 value from dual union all select 1 id, 2 seq, 'T2' type, 1 value from dual union all select 1 id, 3 seq, 'T3' type, 4 value from dual union all select 1 id, 4 seq, 'T2' type, 1 value from dual union all select 2 id, 1 seq, 'T1' type, 4 value from dual union all select 2 id, 2 seq, 'T2' type, 5 value from dual) SELECT id, SUM(decode(TYPE, 'T1', VALUE, 0)) t1, SUM(decode(TYPE, 'T2', VALUE, 0)) T2, SUM(decode(TYPE, 'T3', VALUE, 0)) T3 FROM tt GROUP BY id;
------解决方案--------------------