日期:2014-05-17  浏览次数:21090 次

关于oracle 行数据转换成列数据

不要用下列代码给我
我要的是对字段操作,不要对数据操作
SQL code

with web_wlms_o4sequence_user(cod_mitem, rot_ord, plan_wkhr_m, plan_wkhr_no, status)
as (
          select 'Z12009-M01', 01, '10.000', 7, '01' from dual
union all select 'Z12009-M01', 14, '20.000', 13, '01' from dual
union all select 'Z12009-M01', 15, '20.000', 3, '02' from dual
union all select 'Z12009-M01', 15, '20.000', 2, '00' from dual
union all select 'Z12009-M01', 15, '20.000', 2, '01' from dual
union all select 'Z12009-M01', 15, '20.000', 6, '01' from dual
)
select cod_mitem 工程机号, rot_ord 工程令次, plan_wkhr_m 令次分配工时,
sum(plan_wkhr_no) 令次总派工时,
sum(decode(status, '00', plan_wkhr_no)) 审核中工时,
sum(decode(status, '01', plan_wkhr_no)) 审核通过,
sum(decode(status, '02', plan_wkhr_no)) 退审工时
from web_wlms_o4sequence_user group by cod_mitem, rot_ord, plan_wkhr_m
order by 1,2,3;



------解决方案--------------------
探讨
不要用下列代码给我
我要的是对字段操作,不要对数据操作