SQL 16)统计出当前各个title类型对应的员工当前薪水对应的平均工资
统计出当前各个title类型对应的员工当前薪水对应的平均工资
http://www.nowcoder.com/questionTerminal/c8652e9e5a354b879e2a244200f1eaae
方法)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;