什么逻辑都不写,我们怎么知道你要怎么变?楼主是大坑

解决方案 »

  1.   

    with t as
    (select  -1 a, 1 b, 0 c, 100 d,'x1' e,25 f from dual union all
    select  -1, 1, 0, 100,  'x2', 31 from dual union all
    select  -1, 1, 0, 100,  'x3', 26 from dual union all
    select  -1, 1, 1, 200,  'x1', 14 from dual union all
    select  -1, 1, 1, 200,  'x2', 43 from dual union all
    select  -1, 1, 1, 200,  'x3', 46 from dual union all
    select  -1, 1, 2, 300,  'x1', 38 from dual union all
    select  -1, 1, 2, 300,  'x2', 29 from dual union all
    select  -1, 1, 2, 300,  'x3', 30 from dual)
     select a,
            b,
            max(decode(d, 100, d)) d1,
            max(decode(d, 200, d)) d2,
            max(decode(d, 300, d)) d3,
            e,
            max(decode(d, 100, f)) f1,
            max(decode(d, 200, f)) f2,
            max(decode(d, 300, f)) f3
       from t
      group by a, b, e