题解 | #统计出当前各个title类型对应的员工当前薪水对应的平均工资#
统计出当前各个title类型对应的员工当前薪水对应的平均工资
http://www.nowcoder.com/practice/c8652e9e5a354b879e2a244200f1eaae
各个title类型对应的员工薪水对应的平均工资avg
Select titles.title, avg(salaries.salary) as avg from titles, salaries
两个表联系起来的基础是:where titles.emp_no=salaries.emp_no
考虑到在职:and titles.to_date= '9999-01-01' and salaries.to_date='9999-01-01'
整体解答:
Select titles.title, avg(salaries.salary) as avg from titles, salaries
where titles.emp_no=salaries.emp_no
and titles.to_date= '9999-01-01' and salaries.to_date='9999-01-01'
group by title
order by avg