日期:2014-05-17 浏览次数:20868 次
select to_char(run_date, 'yyyy-mm-dd') as run_date,
max(case team_name when '甲值' then team_name else '' end) as jiazhi,
max(case team_name when '乙值' then team_name else '' end) as yizhi,
max(case team_name when '丙值' then team_name else '' end) as binzhi,
max(case team_name when '丁值' then team_name else '' end) as dinzhi,
max(case team_name when '戊值' then team_name else '' end) as wuzhi,
begin_time
from V_work_time t group by run_date,team_name,begin_time order by t.run_date desc,begin_time asc
select SUM(run_date) '值班日期',SUM(jia) '甲值时间',SUM(yi) '乙值时间',SUM(bing) '丙值时间',SUM(ding) '丁值时间',SUM(wu) '戊值时间'
from (
select run_date,begin_time jia,0 yi,0 bing,0 ding,0 wu
from V_work_time where team_name='甲值'
union all
select run_date,0 jia,begin_time yi,0 bing,0 ding,0 wu
from V_work_time where team_name='乙值'
union all
select run_date,0 jia,0 yi,begin_time bing,0 ding,0 wu
from V_work_time where team_name='丙值'
union all
select run_date,0 jia,0 yi,0 bing,begin_time ding,0 wu
from V_work_time where team_name='丁值'
union all
select run_date,0 jia,0 yi,0 bing,0 ding,begin_time wu
from V_work_time where team_name='戊值'
);
CREATE OR REPLACE PROCEDURE T_TEST
IS
V_SQL NVARCHAR2(2000);
CURSOR CURSOR_1 IS
SELECT team_name
FROM teamtab T;
BEGIN
&n