方法1)员工入职时的薪水记录日期 即 员工入职日期
SELECT e.emp_no, s.salary FROM employees AS e JOIN salaries AS s ON e.emp_no = s.emp_no WHERE e.hire_date = s.from_date -- 员工入职日期 ORDER BY e.emp_no DESC;
方法2)员工入职时的薪水记录日期 即 每个员工工资记录的最小日期
SELECT e.emp_no, s.salary FROM employees AS e JOIN salaries AS s ON e.emp_no = s.emp_no WHERE (e.emp_no, s.from_date) IN ( -- 每个员工工资记录的最小日期 SELECT emp_no, MIN(from_date) FROM salaries GROUP BY emp_no) ORDER BY emp_no DESC;