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
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
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
小弟用纯SQL搞不定你的问题!
存SQL搞不定
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
看楼主的需要了,是需要最大的,还是做统计。
SQL> desc list
名称 是否为空? 类型
----------------------------------------- -------- --------------
DAY VARCHAR2(20)
FIELD1 VARCHAR2(20)
FIELD2 VARCHAR2(20)