111,126
社区成员
发帖
与我相关
我的任务
分享create or replace procedure UP_GetDBDataOfMonth(QK in varchar2,JH in varchar2,starttime In
varchar2,endtime in varchar2,cur_out Out sys_refcursor)
as
begin
if JH is not null then
open cur_out for
select t.ms as th011a,t.Qo as th015a,t.Qw as th016a,t.Ql as th017a,sum(t.Qo)over(ORDER BY t.ms) as th013a,sum(t.Qw)over(ORDER BY t.ms) as th012a,sum(t.Ql)over(ORDER BY t.ms) as th014a,round(decode(t.Ql,0,0,t.Qw/t.Ql),4) as th019a,round(decode(t.Qo,0,0,t.Qw/t.Qo),4) as th020a,round(decode(t.Qo,0,0,t.Ql/t.Qo),4) as th022a from
(select NY as ms,sum(COALESCE(HSYCSL+HSYCYL,0)) as Ql,sum(COALESCE(HSYCYL,0)) as Qo,sum(COALESCE(HSYCSL,0)) as Qw from ydcl.yd_dba04@KF_DBLINK WHERE NY between to_char(to_date(starttime,'yyyy-mm-dd'),'yyyymm') and to_char(to_date(endtime,'yyyy-mm-dd'),'yyyymm') And jh IN (SELECT * FROM TABLE(CAST(split(JH,',') AS mytable))) group by NY ORDER BY ms) t;
else
open cur_out for
select t.ms as th011a,t.Qo as th015a,t.Qw as th016a,t.Ql as th017a,sum(t.Qo)over(ORDER BY t.ms) as th013a,sum(t.Qw)over(ORDER BY t.ms) as th012a,sum(t.Ql)over(ORDER BY t.ms) as th014a,round(decode(t.Ql,0,0,t.Qw/t.Ql),4) as th019a,round(decode(t.Qo,0,0,t.Qw/t.Qo),4) as th020a,round(decode(t.Qo,0,0,t.Ql/t.Qo),4) as th022a from (select NY as ms,sum(COALESCE(HSYCSL+HSYCYL,0)) as Ql,sum(COALESCE(HSYCYL,0)) as Qo,sum(COALESCE(HSYCSL,0)) as Qw from ydcl.yd_dbb01@KF_DBLINK WHERE NY between to_char(to_date(starttime,'yyyy-mm-dd'),'yyyymm') and to_char(to_date(endtime,'yyyy-mm-dd'),'yyyymm') And SCGS IN
(SELECT * FROM TABLE(CAST(split(QK,',') AS mytable))) group by NY ORDER BY ms) t;
end if;
end;