方法一:获取salaries中from_data中最小的对应的salary和emp_no,因为salaries可能涨薪,所以这张表一个员工可能有多条记录。
SELECT
emp_no,
salary
FROM
salaries
GROUP BY
emp_no
HAVING
min( from_date )
ORDER BY
emp_no DESC
方法二:hire_data时间和from_data时间一致
SELECT
e.emp_no,
s.salary
FROM
employees AS e
INNER JOIN salaries AS s ON e.emp_no = s.emp_no
AND e.hire_date = s.from_date
ORDER BY
e.emp_no DESC
方法三:hire_data时间和from_data时间一致
SELECT
e.emp_no,
s.salary
FROM
employees AS e,
salaries AS s
WHERE
e.emp_no = s.emp_no
AND e.hire_date = s.from_date
ORDER BY
e.emp_no DESC