下面这条语句怎么优化?
select ch,jxlb,jdrq,a.cjdw from t_jxfy_dx a
where ch||jdrq in (select ch||max(jdrq) from t_jxfy_dx f where jxlb='段修' and sdrq <= sysdate group by ch)
select ch,jxlb,jdrq,a.cjdw from t_jxfy_dx a
where ch||jdrq in (select ch||max(jdrq) from t_jxfy_dx f where jxlb='段修' and sdrq <= sysdate group by ch)
inner join
(select ch||max(jdrq) temp from t_jxfy_dx f where jxlb='段修' and sdrq <= sysdate group by ch)t
on t.temp = a1.ch||a1.jdrq
where ch||jdrq exists (select ch||max(jdrq) from t_jxfy_dx f where jxlb='段修' and sdrq <= sysdate group by ch)
用exists应该和in差不多
select ch,jxlb,max(jdrq),cjdw from t_jxfy_dx
where jxlb='段修' and sdrq <= sysdate
group by ch,jxlb,cjdw
where exists
(select 0 from (select ch,max(jdrq) jdrq from t_jxfy_dx f where jxlb='段修' and sdrq <= sysdate group by ch) c
where c.cb=a.cb and c.jdrq=a.jdrq