首页新闻找找看学习计划

Oracle数据存储中数据累计的问题,请大神帮忙?谢谢

0
[待解决问题]

PROCEDURE P_WT_B501(V_AREACODE IN STRING,
START_DATE IN STRING,
END_DATE IN STRING,
XNH_BB_501_CURSOR OUT T_CURSOR) IS
LL_START DATE;
LL_END DATE;
TABLE_NAME VARCHAR2(20);
BEGIN
LL_START := TO_DATE(START_DATE || ' 00:00:00', 'yyyy-mm-dd hh24:mi:ss');
LL_END := TO_DATE(END_DATE || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss');

OPEN XNH_BB_501_CURSOR FOR

select
D01,--本月次数
D02---累计次数-----

from (
select
sum(case when mytp =2 and d504_45 in(11,14) then 1 else 0 end ) d01,---本月次数-----
sum(case when mytp =2 and d504_45 in(11,14) then 1 else 0 end ) d02---累计次数-----累计是累计当年的
from (
select 1 sum1,d504_25,d504_53,hospital_level lv,d504_45,1 mytp,0 d501_30,D504_113,D504_114,D504_55 from d504 ,sy_dept where d504_24 in ('1','3')
and d504_55 >= LL_START
and d504_55 <= LL_END
and d504_05 like V_AREACODE||'%'
and d504_46 = jg_dm
union all
select 1 sum1,d501_19,d501_27,hospital_level lv,d501_34,2 mytp,d501_30,D501_84,D501_83,D501_18 from d501 ,sy_dept where d501_15 in ('1','3')
and d501_18 >= LL_START
and d501_18 <= LL_END
and d501_09 like V_AREACODE||'%'
and d501_17 = jg_dm
) t
);
end;

 

 

请大神帮忙修改一下,累计的,我不知道怎么搞,谢谢大家,帮帮忙

那年夏天见到你的主页 那年夏天见到你 | 菜鸟二级 | 园豆:214
提问于:2016-11-30 12:08
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册