9.获取所有部门当前manager的当前薪水情况,给出dept_

2018-07-03  本文已影响0人  Bre_eze

获取所有部门当前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`));

解析:主要考察表的连结

select de.dept_no, de.emp_no, sa.salary
from dept_manager as de, salaries as sa
where de.emp_no = sa.emp_no
and de.to_date = '9999-01-01'
and sa.to_date = '9999-01-01';
上一篇下一篇

猜你喜欢

热点阅读