方法)AVG + GROUP BY
- 当前(titles.to_date='9999-01-01')各个title类型
- 员工当前(salaries.to_date='9999-01-01')薪水
SELECT t.title, AVG(s.salary) FROM salaries AS s JOIN titles AS t ON s.emp_no = t.emp_no WHERE t.to_date = '9999-01-01' AND s.to_date = '9999-01-01' GROUP BY t.title;