优化这个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
)
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
)
解决方案 »
- 现表table中有一字段value ,但字段value的值都为null ,我想给value字段设置默认值都为2 ,请问怎么设置?
- 请问各位高手:怎样新建oracle数据库的例程???
- plsql过程问题,如何将一个索引表插入到对应的表中,
- ora-04030错误。
- ORACLE的插入实时性问题
- 请教SQL语句:如何在order by后再获取前100条的记录???
- 华东理工的编程人进来!群6213544!方便交流!~有意者加入啊!
- sql语句问题
- 导入需要这么久吗?
- 请问,那有Oracle的电子书籍下载???
- 求一sql语句,谢谢!!!!!!有分!!!!!!!!
- sql server数据迁移到oracl时出现的问题
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
)
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,
(select max(a.emp_post_id) as emp_post_id
from t_hr_b_post a,
(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 a.emp_id
) c
where confirmflag = '00590002' and a.post_code = b.post_code and c.emp_post_id = b.emp_post_id
谢谢大家,但都没有解决实质性问题,所以说是给两百分,现在就给一百分