简单统计报表例子(存储过程)

来源:互联网 发布:企业网站如何做好优化 编辑:程序博客网 时间:2024/06/06 13:13
 1 create or replace procedure bb_quxzbmjdqzxfqk_ces(kssj in date, 2                                          jssj in date, 3                                          wtsd2 varchar2, 4                                          tjjg out sys_refcursor) as 5  6 begin 7    delete from A_TJBB_quxzbmjdqzxfqk; 8 commit; 9 insert into A_TJBB_quxzbmjdqzxfqk10 select jj.iidd,jj.isedit,jj.djjgbh,jj.cfxfjbz,jj.lmbz,jj.xfrs,jj.xfxs from visit_xfj jj,11  hr_organization n where n.jglb='1200' and  n.region_dm=wtsd2 and n.bh=jj.djjgbh and jj.djsj between kssj and jssj;12 commit;13   open tjjg for14 15 16 select l.mc as mc,17  count(1) as jianci,18 sum(case when xf.xfxs='100' then 1 else19  case when xf.xfxs='200' then xf.xfrs else20  case when xf.xfxs in ('300','303') then 121  else 0 end end end) as rci,22 sum(case when xf.xfxs='100' and xf.lmbz='0'and xf.cfxfjbz='0' then 1 else 0 end)as grlx,23 sum(case when xf.xfxs='100' and xf.lmbz='1'and xf.cfxfjbz='0' then 1 else 0 end)as lmx,24 sum(case when xf.xfxs='100' and xf.lmbz='0'and xf.cfxfjbz='1' then 1 else 0 end)as cfgrlx,25 sum(case when xf.xfxs='100' and xf.lmbz='1'and xf.cfxfjbz='1' then 1 else 0 end)as cflmx,26 sum(case when xf.xfxs='100' then 1 else 0 end)as xiaojie,27 sum(case when xf.xfxs='200' and xf.xfrs<=4 and xf.cfxfjbz='0' then 1 else 0 end)as c1lfcjjc,28 sum(case when xf.xfxs='200' and xf.xfrs<=4 and xf.cfxfjbz='0' then xf.xfrs else 0 end)as c1lfcjrc,29 sum(case when xf.xfxs='200' and( xf.xfrs>=5 and xf.xfrs<=49) and xf.cfxfjbz='0' then 1 else 0 end)as c5lfcjjc,30 sum(case when xf.xfxs='200' and( xf.xfrs>=5 and xf.xfrs<=49) and xf.cfxfjbz='0' then xf.xfrs else 0 end)as c5lfcjrc,31 sum(case when xf.xfxs='200' and( xf.xfrs>=50 and xf.xfrs<=499) and xf.cfxfjbz='0' then 1 else 0 end)as c50lfcjjc,32 sum(case when xf.xfxs='200' and( xf.xfrs>=50 and xf.xfrs<=499) and xf.cfxfjbz='0' then  xf.xfrs else 0 end)as c50lfcjrc,33 sum(case when xf.xfxs='200' and xf.xfrs>=500 and xf.cfxfjbz='0' then 1 else 0 end)as c500lfcjjc,34 sum(case when xf.xfxs='200' and xf.xfrs>=500 and xf.cfxfjbz='0' then  xf.xfrs else 0 end)as c500lfcjrc,35 sum(case when xf.xfxs='200' and xf.xfrs<=4 and xf.cfxfjbz='1' then 1 else 0 end)as cf1lfcjjc,36 sum(case when xf.xfxs='200' and xf.xfrs<=4 and xf.cfxfjbz='1' then xf.xfrs else 0 end)as cf1lfcjrc,37 sum(case when xf.xfxs='200' and( xf.xfrs>=5 and xf.xfrs<=49) and xf.cfxfjbz='1' then 1 else 0 end)as cf5lfcjjc,38 sum(case when xf.xfxs='200' and( xf.xfrs>=5 and xf.xfrs<=49) and xf.cfxfjbz='1' then xf.xfrs else 0 end)as cf5lfcjrc,39 sum(case when xf.xfxs='200' and( xf.xfrs>=50 and xf.xfrs<=499) and xf.cfxfjbz='1' then 1 else 0 end)as cf50lfcjjc,40 sum(case when xf.xfxs='200' and( xf.xfrs>=50 and xf.xfrs<=499) and xf.cfxfjbz='1' then  xf.xfrs else 0 end)as cf50lfcjrc,41 sum(case when xf.xfxs='200' and xf.xfrs>=500 and xf.cfxfjbz='1' then 1 else 0 end)as cf500lfcjjc,42 sum(case when xf.xfxs='200' and xf.xfrs>=500 and xf.cfxfjbz='1' then  xf.xfrs else 0 end)as cf500lfcjrc,43 sum(case when xf.xfxs='200' then 1 else 0 end)as lxxiaojjc,44 sum(case when xf.xfxs='200' then xf.xfrs else 0 end)as lxxiaojrc,45 sum(case when xf.xfxs in('300','303') and xf.cfxfjbz='0'and xf.lmbz='0' then 1 else 0 end) as grts,46 sum(case when xf.xfxs in('300','303') and xf.cfxfjbz='0'and xf.lmbz='1' then 1 else 0 end) as lmts,47 48 sum(case when xf.xfxs in('300','303') and xf.cfxfjbz='1'and xf.lmbz='0' then 1 else 0 end) as cfgrts,49 50 sum(case when xf.xfxs in('300','303') and xf.cfxfjbz='1'and xf.lmbz='1' then 1 else 0 end) as cflmts,51 sum(case when xf.xfxs in('300','303') then 1 else 0 end) as xiaoji52 53   from hr_organization l,A_TJBB_quxzbmjdqzxfqk xf where  l.jglb='1200' and  l.region_dm='500101' and l.bh=xf.djjgbh group by l.mc;54 55   end bb_quxzbmjdqzxfqk_ces;
复制代码

————————————————————————————————————————————————————————————————————

复制代码
 1 create or replace procedure bb_quxzbmjdqzxfqk_ces(kssj in date, 2                                          jssj in date, 3                                          wtsd2 varchar2, 4                                          isquxian varchar2, 5                                          tjjg out GLOBALPKG.RCT1) as 6  7 begin 8    v_kssj1 :=kssj; 9    v_jssj1 :=jssj;10   open tjjg for11 12 13 select l.mc as mc,14  count(1) as jianci,15 sum(case when xf.xfxs='100' then 1 else16  case when xf.xfxs='200' then xf.xfrs else17  case when xf.xfxs in ('300','303') then 118  else 0 end end end) as rci,19 sum(case when xf.xfxs='100' and xf.lmbz='0'and xf.cfxfjbz='0' then 1 else 0 end)as grlx,20 sum(case when xf.xfxs='100' and xf.lmbz='1'and xf.cfxfjbz='0' then 1 else 0 end)as lmx,21 sum(case when xf.xfxs='100' and xf.lmbz='0'and xf.cfxfjbz='1' then 1 else 0 end)as cfgrlx,22 sum(case when xf.xfxs='100' and xf.lmbz='1'and xf.cfxfjbz='1' then 1 else 0 end)as cflmx,23 sum(case when xf.xfxs='100' then 1 else 0 end)as xiaojie,24 sum(case when xf.xfxs='200' and xf.xfrs<=4 and xf.cfxfjbz='0' then 1 else 0 end)as c1lfcjjc,25 sum(case when xf.xfxs='200' and xf.xfrs<=4 and xf.cfxfjbz='0' then xf.xfrs else 0 end)as c1lfcjrc,26 sum(case when xf.xfxs='200' and( xf.xfrs>=5 and xf.xfrs<=49) and xf.cfxfjbz='0' then 1 else 0 end)as c5lfcjjc,27 sum(case when xf.xfxs='200' and( xf.xfrs>=5 and xf.xfrs<=49) and xf.cfxfjbz='0' then xf.xfrs else 0 end)as c5lfcjrc,28 sum(case when xf.xfxs='200' and( xf.xfrs>=50 and xf.xfrs<=499) and xf.cfxfjbz='0' then 1 else 0 end)as c50lfcjjc,29 sum(case when xf.xfxs='200' and( xf.xfrs>=50 and xf.xfrs<=499) and xf.cfxfjbz='0' then  xf.xfrs else 0 end)as c50lfcjrc,30 sum(case when xf.xfxs='200' and xf.xfrs>=500 and xf.cfxfjbz='0' then 1 else 0 end)as c500lfcjjc,31 sum(case when xf.xfxs='200' and xf.xfrs>=500 and xf.cfxfjbz='0' then  xf.xfrs else 0 end)as c500lfcjrc,32 sum(case when xf.xfxs='200' and xf.xfrs<=4 and xf.cfxfjbz='1' then 1 else 0 end)as cf1lfcjjc,33 sum(case when xf.xfxs='200' and xf.xfrs<=4 and xf.cfxfjbz='1' then xf.xfrs else 0 end)as cf1lfcjrc,34 sum(case when xf.xfxs='200' and( xf.xfrs>=5 and xf.xfrs<=49) and xf.cfxfjbz='1' then 1 else 0 end)as cf5lfcjjc,35 sum(case when xf.xfxs='200' and( xf.xfrs>=5 and xf.xfrs<=49) and xf.cfxfjbz='1' then xf.xfrs else 0 end)as cf5lfcjrc,36 sum(case when xf.xfxs='200' and( xf.xfrs>=50 and xf.xfrs<=499) and xf.cfxfjbz='1' then 1 else 0 end)as cf50lfcjjc,37 sum(case when xf.xfxs='200' and( xf.xfrs>=50 and xf.xfrs<=499) and xf.cfxfjbz='1' then  xf.xfrs else 0 end)as cf50lfcjrc,38 sum(case when xf.xfxs='200' and xf.xfrs>=500 and xf.cfxfjbz='1' then 1 else 0 end)as cf500lfcjjc,39 sum(case when xf.xfxs='200' and xf.xfrs>=500 and xf.cfxfjbz='1' then  xf.xfrs else 0 end)as cf500lfcjrc,40 sum(case when xf.xfxs='200' then 1 else 0 end)as lxxiaojjc,41 sum(case when xf.xfxs='200' then xf.xfrs else 0 end)as lxxiaojrc,42 sum(case when xf.xfxs in('300','303') and xf.cfxfjbz='0'and xf.lmbz='0' then 1 else 0 end) as grts,43 sum(case when xf.xfxs in('300','303') and xf.cfxfjbz='0'and xf.lmbz='1' then 1 else 0 end) as lmts,44 45 sum(case when xf.xfxs in('300','303') and xf.cfxfjbz='1'and xf.lmbz='0' then 1 else 0 end) as cfgrts,46 47 sum(case when xf.xfxs in('300','303') and xf.cfxfjbz='1'and xf.lmbz='1' then 1 else 0 end) as cflmts,48 sum(case when xf.xfxs in('300','303') then 1 else 0 end) as xiaoji49 50   from hr_organization l,A_TJBB_quxzbmjdqzxfqk xf where  l.region_dm='500101' and   ((v_kssj1 is not null and j.adddatetime between v_kssj1 and v_jssj1) 51 or (v_kssj1 is not nulll and 1=1))  and((isquxian is not null and ion.dm = isquxian ) or (isquxian is null and 1 = 1)) and l.jglb='1200' and 52 53 l.bh=xf.djjgbh group by l.mc;54 55   end bb_quxzbmjdqzxfqk_ces;
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 猫被皮筋绑久肿了怎么办 抗链0高关节疼怎么办 近视800度老了怎么办 军检体重不达标怎么办 到交房租没有钱怎么办 房租没到期房东要收回怎么办 客户指定发快递我要怎么办? 跨境汇款被退回怎么办 汇款途径写错了怎么办 快递被菜鸟驿站退回怎么办 电脑登录账户已锁定怎么办 被外管局查到境外汇款买房怎么办 军校生复检被刷怎么办 企业私刻章拿去挂项目怎么办? 中通快递被退回怎么办 网易邮箱提示被修复怎么办 小孩屁股烫红了怎么办 8岁近视400度怎么办 部队体能差的人怎么办 上环5天同房了怎么办 肾结石有3mm了怎么办 4*3mm肾结石好痛怎么办 做完肾结石积水后迟续发烧怎么办 血糖高有肾结石反复发高烧怎么办 肾里面有小结石怎么办 大于2厘米的结石怎么办 双肾结石肾盏扩张怎么办 边防消防警卫部队改革义务兵怎么办 汽车年检尾气复检不合格怎么办 车辆年检尾气不合格复检怎么办? 在瓜子上买车复检有问题怎么办 更换车壳车架号怎么办 吸完甲醛的绿萝怎么办 如果公务员复检不合格有异议怎么办 国考公务员政审没有毕业证怎么办 打针硬块4年不消怎么办 外墙补起来难看不好卖怎么办 杠精现实中应该怎么办 发现记者报道假新闻怎么办 2018消防兵转制到期士官怎么办 小孩睡觉老想着军训怎么办