以下是给我错误的查询:
查询:
select distinct
i.edg_trace_id,
i.*
from ed_indv_counters i,
ed_temp e
where e.case_num = '720335'
and e.payment_beg_dt<'30-JUL-2017'
and e.program_cd = 'TF'
and e.delete_sw='N'
and di_ind='Y'
and counter_type_cd='TLP'
and i.edg_trace_id in (
CASE e.current_elig_ind
WHEN 'P' then e.edg_trace_id
ELSE (
Select e1.edg_trace_id
from ed_temp e1
where e1.case_num='720335'
and e1.program_cd = 'TF'
and e1.delete_sw='N'
and e1.current_elig_ind='A'
and e1.payment_beg_dt not in (
select payment_beg_dt
from ed_temp e2
where e2.current_elig_ind='P'
and e2.case_num='720335'
and e2.delete_sw='N'
and e2.program_cd = 'TF'
)
)
END
)
order by i.counter_begin_dt;
答案 0 :(得分:0)
您可以尝试使用UNION ALL
和互斥过滤器而不是CASE
声明:
select distinct
i.edg_trace_id,
i.*
from ed_indv_counters i,
ed_temp e
where e.case_num = '720335'
and e.payment_beg_dt < DATE '2017-07-30' -- Use a date literal rather than string
and e.program_cd = 'TF'
and e.delete_sw='N'
and di_ind='Y'
and counter_type_cd='TLP'
and i.edg_trace_id in (
SELECT e.edg_trace_id
FROM DUAL
WHEN e.current_elig_ind = 'P'
UNION ALL
Select e1.edg_trace_id
from ed_temp e1
where ( e.current_elig_ind <> 'P' OR e.current_elig_ind IS NULL )
and e1.case_num='720335'
and e1.program_cd = 'TF'
and e1.delete_sw='N'
and e1.current_elig_ind='A'
and e1.payment_beg_dt not in (
select payment_beg_dt
from ed_temp e2
where e2.current_elig_ind='P'
and e2.case_num='720335'
and e2.delete_sw='N'
and e2.program_cd = 'TF'
)
)
order by i.counter_begin_dt;