工作中写的报表sql

select (select t.uco_desc
          from r5ucodes t
         where t.uco_rentity = 'JBTP'
           AND t.uco_rcode = 'ST'
           AND T.UCO_CODE = r.evt_jobtype) TYPE,
       
       (select t.MRC_desc from R5MRCS t where T.MRC_CODE = r.evt_MRC) BM,
       (select t.crw_desc from R5CREWS t where t.crw_code = r.evt_udfchar11) BZ,
       r.evt_class,
       (SELECT t.cls_desc from R5classes T WHERE T.CLS_CODE = R.EVT_CLASS) ZY,
       count(*) ZPS,
       
       (select count(evt_status)
  from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P01')) TX, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P02')) QF, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P03')) DJQF, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P04')) JS, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P05')) PZ, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P06')) ACZX, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P07')) XK, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P08', 'P12', 'P13')) ZX, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P09')) YZX, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P11')) WZX, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P14')) ZJ, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P00')) ZF, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P15')) XFSH, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P16')) AJSH, (select count(evt_status) from r5events r5
 where (r5.evt_jobtype = r.evt_jobtype or
       (r5.evt_jobtype is null and r.evt_jobtype is null))
   and (r5.evt_mrc = r.evt_mrc or
       (r5.evt_mrc is null and r.evt_mrc is null))
   and (r5.evt_udfchar11 = r.evt_udfchar11 or
       (r5.evt_udfchar11 is null and r.evt_udfchar11 is null))
   and (r5.evt_class = r.evt_class
    or (r5.evt_class is null and r.evt_class is null)
 )
   and r5.evt_status in ('P17')) DHCL

 from r5events r
 where r.evt_jobtype in ('P-DQ1',
                         'P-DQ2',
                         'P-RJ1',
                         'P-RJ2',
                         'P-RK1',
                         'P-RK2',
                         'P-DH1',
                         'P-DH2',
                         'P-JB')
   and r.evt_udfchar04 = 'GZ'
 group by r.evt_jobtype, r.evt_mrc, r.evt_udfchar11, r. evt_class

 order by r.evt_jobtype;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值