获取所有部门当前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 d.dept_no, d.emp_no, s.salary
from salaries as s inner join dept_manager as d
on s.emp_no = d.emp_no
and d.to_date=s.to_date
and d.to_date='9999-01-01'
本文介绍了一种通过SQL查询来获取所有部门当前经理的薪资详情的方法,包括部门编号、员工编号及具体的薪资数额。
723

被折叠的 条评论
为什么被折叠?



