union一例,oracle上的union会自动把重复的列去掉

[code]
--当该人是选案人员时
select qt.ajbh, qt.lrajbh, nsr.nsrsbh, nsr.nsrmc, jg.swjg_mc, zt.jczt_mc, qt.sfla
from
ctais2wg.t03_qtajxx qt
,ctais2wg.t03_ayxsqc ay
,ctais2wg.dm_jczt zt
,ctais2wg.dj_nsrxx nsr
,ctais2wg.dm_swjg jg
where
qt.AYXSCLR_DM = '14401000192' --该人是选案经办人
and qt.AJZXWBRQ is null --该案件没有执行完毕
and (sysdate - qt.ZGAJWCRQ) > 25 --已经超出原定完成日期特定的天数
and (
qt.AYCLRQ is not null and qt.JCRWXDRQ is null
) --该案件仍然在选案环节没有做完
and qt.ajbh = ay.ajbh
and qt.jczt_dm = zt.jczt_dm
and ay.LRDW_BM = jg.swjg_dm
and ay.nsrsbh = nsr.nsrsbh
union
--当该人是检查人员时
select qt.ajbh, qt.lrajbh, nsr.nsrsbh, nsr.nsrmc, jg.swjg_mc, zt.jczt_mc, qt.sfla
from
ctais2wg.t03_qtaj_jcry jcr
,ctais2wg.t03_qtajxx qt
,ctais2wg.t03_ayxsqc ay
,ctais2wg.dm_jczt zt
,ctais2wg.dj_nsrxx nsr
,ctais2wg.dm_swjg jg
where
jcr.jcry_dm = '14401000192' --该人负责检查环节
and jcr.yxbz = 'Y'
and jcr.ajbh = qt.ajbh --该人负责的检查环节中包含该案件的检查环节
and qt.AJZXWBRQ is null --该案件没有执行完毕
and (sysdate - qt.ZGAJWCRQ) > 25 --已经超出原定完成日期特定的天数
and (
(qt.sfla='Y' and qt.JCRWXDRQ is not null and qt.TJSLSRQ is null)
or
(qt.sfla='N' and qt.JCRWXDRQ is not null and qt.CLJDSFSRQ is null and qt.JCJLFSRQ is null)
) --该案件的检查环节仍然没有做完
--and qt.JCRWXDRQ is not null and qt.TJSLSRQ is null and qt.CLJDSFSRQ is null and qt.JCJLFSRQ is null --考虑到速度问题时可以用这条代替‘检查环节没完成’的功能
and qt.ajbh = ay.ajbh
and qt.jczt_dm = zt.jczt_dm
and ay.LRDW_BM = jg.swjg_dm
and ay.nsrsbh = nsr.nsrsbh
union
--当该人是审理人员时
select qt.ajbh, qt.lrajbh, nsr.nsrsbh, nsr.nsrmc, jg.swjg_mc, zt.jczt_mc, qt.sfla
from
ctais2wg.t03_qtaj_slry slr
,ctais2wg.t03_qtajxx qt
,ctais2wg.t03_ayxsqc ay
,ctais2wg.dm_jczt zt
,ctais2wg.dj_nsrxx nsr
,ctais2wg.dm_swjg jg
where
slr.slry_dm = '14401000192' --该人负责审理环节
and slr.yxbz = 'Y'
and slr.ajbh = qt.ajbh --该人负责的审理环节中包含该案件的检查环节
and qt.AJZXWBRQ is null --该案件没有执行完毕
and (sysdate - qt.ZGAJWCRQ) > 25 --已经超出原定完成日期特定的天数
and (
(qt.sfla='Y' and qt.TJSLSRQ is not null
and qt.CLJDSFSRQ is null and qt.JCJLFSRQ is null --非重大审
and qt.ZDSWASLTQSRQ is null) --重大审
) --该案件的审理环节仍然没有做完
and qt.ajbh = ay.ajbh
and qt.jczt_dm = zt.jczt_dm
and ay.LRDW_BM = jg.swjg_dm
and ay.nsrsbh = nsr.nsrsbh
union
--当该人是执行人员
select qt.ajbh, qt.lrajbh, nsr.nsrsbh, nsr.nsrmc, jg.swjg_mc, zt.jczt_mc, qt.sfla
from
ctais2wg.t03_qtaj_zxry zxr
,ctais2wg.t03_qtajxx qt
,ctais2wg.t03_ayxsqc ay
,ctais2wg.dm_jczt zt
,ctais2wg.dj_nsrxx nsr
,ctais2wg.dm_swjg jg
where
zxr.zxry_dm = '14401000192' --该人负责执行环节
and zxr.yxbz = 'Y'
and zxr.ajbh = qt.ajbh --该人负责的执行环节中包含该案件的检查环节
and qt.AJZXWBRQ is null --该案件没有执行完毕
and (sysdate - qt.ZGAJWCRQ) > 25 --已经超出原定完成日期特定的天数
and (
qt.CLJDSFSRQ is not null or qt.JCJLFSRQ is not null
) --该案件的执行环节仍然没有做完
and qt.ajbh = ay.ajbh
and qt.jczt_dm = zt.jczt_dm
and ay.LRDW_BM = jg.swjg_dm
and ay.nsrsbh = nsr.nsrsbh

[/code]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值