select * from COREMOUNT.FJ_LEAVE_APPLIES
where 1=1
and OWNER = 'yszx10'
and cast(leave_apply_id as VARCHAR2(20) ) not in
(select key1 from b_t_ack_rslt
where ACK_KIND_CD='5hf6d8fa32hzt9t'
union
select distinct bm.key1 from b_m_ack_rslt bm
where bm.ACK_KIND_CD ='5hf6d8fa32hzt9t' )
order by LEAVE_APPLY_ID desc
where 1=1
and OWNER = 'yszx10'
and cast(leave_apply_id as VARCHAR2(20) ) not in
(select key1 from b_t_ack_rslt
where ACK_KIND_CD='5hf6d8fa32hzt9t'
union
select distinct bm.key1 from b_m_ack_rslt bm
where bm.ACK_KIND_CD ='5hf6d8fa32hzt9t' )
order by LEAVE_APPLY_ID desc
改成:leave_apply_id
where 1=1
and OWNER = 'yszx10'
and cast(leave_apply_id as VARCHAR2(20) ) not exists(
select key1 from
(select key1 from b_t_ack_rslt
where ACK_KIND_CD='5hf6d8fa32hzt9t'
union
select distinct bm.key1 from b_m_ack_rslt bm
where bm.ACK_KIND_CD ='5hf6d8fa32hzt9t' )t2
where t1.key1=t2.key1
)
order by LEAVE_APPLY_ID desc
(select key1 from b_t_ack_rslt
where ACK_KIND_CD='5hf6d8fa32hzt9t'
union all
select bm.key1 from b_m_ack_rslt bm
where bm.ACK_KIND_CD ='5hf6d8fa32hzt9t' ) t2
where 1=1
and OWNER = 'yszx10'
and t1.leave_apply_id = to_number(t2.key1)(+) and t1.leave_apply_id is null
order by LEAVE_APPLY_ID desc
where OWNER = 'yszx10'
and not exists
(
select * from (select key1 from b_t_ack_rslt
where ACK_KIND_CD='5hf6d8fa32hzt9t'
union
select bm.key1 from b_m_ack_rslt bm
where bm.ACK_KIND_CD ='5hf6d8fa32hzt9t') where cast(leave_apply_id as VARCHAR2(20))=key1)
order by LEAVE_APPLY_ID desc