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;
工作中写的报表sql
最新推荐文章于 2020-09-30 15:18:39 发布