9、获取所有部门当前manager的当前薪水情况

1、题目描述:

获取所有部门当前manager的当前薪水情况,给出dept_no, emp_no以及salary,当前表示to_date='9999-01-01'
CREATE TABLE `dept_manager` (
`dept_no` char(4) NOT NULL,
`emp_no` int(11) NOT NULL,
`from_date` date NOT NULL,
`to_date` date NOT NULL,
PRIMARY KEY (`emp_no`,`dept_no`));
CREATE TABLE `salaries` (
`emp_no` int(11) NOT NULL,
`salary` int(11) NOT NULL,
`from_date` date NOT NULL,
`to_date` date NOT NULL,
PRIMARY KEY (`emp_no`,`from_date`));

输入描述:

输出描述:

dept_no emp_no salary
d001 10002 72527
d004 10004 74057
d003 10005 94692
d002 10006 43311
d006 10010 94409 

2、代码:

select d.dept_no,d.emp_no,s.salary 
from salaries s left join dept_manager d on d.emp_no=s.emp_no
where d.to_date='9999-01-01' and s.to_date='9999-01-01';

猜你喜欢

转载自www.cnblogs.com/guoyu1/p/12242211.html
今日推荐