优化一个SQL语句200分
优化这个SQL语句
select a.post_code, a.inst_code, a.post_name, to_char(b.change_date, 'YYYY-MM-DD ') as change_date
from t_hr_b_post b, t_mgt_post a
where confirmflag = '00590002 ' and a.post_code = b.post_code and
exists(select 1
from (select max(emp_post_id) as emp_post_id
from t_hr_b_post a
where confirmflag = '00590002 ' and
exists(select 1
from (select emp_id, min(nvl(post_on_type, '0068002 ')) post_on_type
from t_hr_b_post
where confirmflag = '00590002 '
group by emp_id
)b
where a.emp_id = b.emp_id and nvl(a.post_on_type, '0068002 ') = b.post_on_type
)
group by emp_id
) c
where c.emp_post_id = b.emp_post_id
)
[解决办法]
帮你顶,没有时间分析,项目忙的很.
[解决办法]
顶
[解决办法]
楼主把业务逻辑和表结构罗列出来,SQL语句看得我头大。
[解决办法]
是呀,楼主你把你的表结构和业务逻辑给我们说一下,我们才好帮你看啊!
[解决办法]
select a.post_code, a.inst_code, a.post_name, to_char(b.change_date, 'YYYY-MM-DD ') as change_date from
t_hr_b_post b, t_mgt_post a
where confirmflag = '00590002 ' and a.post_code = b.post_code and exists(
select 1 from(
select emp_id, min(nvl(post_on_type, '0068002 ')) post_on_type from t_hr_b_post where confirmflag = '00590002 ' group by emp_id
)b where a.emp_id = b.emp_id and nvl(a.post_on_type, '0068002 ') = b.post_on_type
)
[解决办法]
好多嵌套.一般如果不是很有时间的话大家都没有耐心看的
