select t.day, 
       max(decode(Field1, 'Parts', Field2, null)) Parts,
       max(decode(Field1, 'Process', Field2, null)) Process,
       max(decode(Field1, 'Design', Field2, null)) Design,
       max(decode(Field1, 'Operate', Field2, null)) Operate,
       max(decode(Field1, 'NGG', Field2, null)) NGG,
from (your sql.....) t
group by t.day

解决方案 »

  1.   

    多了个 , select t.day,
    max(decode(Field1, 'Parts', Field2, null)) Parts,
    max(decode(Field1, 'Process', Field2, null)) Process,
    max(decode(Field1, 'Design', Field2, null)) Design,
    max(decode(Field1, 'Operate', Field2, null)) Operate,
    max(decode(Field1, 'NGG', Field2, null)) NGG
    from (your sql.....) t
    group by t.day
      

  2.   

    估计楼主是要动态的,我就只能帮你顶了.
    小弟用纯SQL搞不定你的问题!
      

  3.   

    这样还是有问题,因为Parts,Proess,Design等不定的,可能会增加和删除???
      

  4.   

    动态只有放到PL/SQL中拼一个SQL语句了,
    存SQL搞不定
      

  5.   

    没有问题的
    SQL> select day,
      2  sum(decode(field1,'Parts',field2,0)) Parts,
      3  sum(decode(field1,'Process',field2,0)) process,
      4  sum(decode(field1,'Design',field2,0)) Design,
      5  sum(decode(field1,'Operate',field2,0)) Operate,
      6  sum(decode(field1,'NGG',field2,0)) NGG
      7  from list group by day;DAY                       PARTS    PROCESS     DESIGN    OPERATE        NGG
    -------------------- ---------- ---------- ---------- ---------- ----------
    2005-10-22                    4          6         10          5          5
    2005-10-23                    7          8         40         50          3
    2005-10-24                    2          4          8          7          4
      

  6.   

    楼上zzwind5()  使用的max ,我这里是sum ,
    看楼主的需要了,是需要最大的,还是做统计。
    SQL> desc list
     名称                                      是否为空? 类型
     ----------------------------------------- -------- --------------
     DAY                                                VARCHAR2(20)
     FIELD1                                             VARCHAR2(20)
     FIELD2                                             VARCHAR2(20)