一个是告诉了一个人头衔是啥
一个是告诉了一个人工资多少
查询的话就是将两张表连在一起就是最后的查询的总表
于是有
select t.title, avg(s.salaries) from titles as t join salaries as s where t.emp_no = s.emp_no;
又因为要各个title对应的员工薪资情况,所以要分组,以title为分组依据,将各个工资合起来
因为分组后合起来了,所以上面的用的是 avg(s.salaries)
所以,追加
select t.title, avg(s.salaries) from titles as t join salaries as s where t.emp_no = s.emp_no group by t.title;
因为又要按照公司平均薪资升序,于是就有
select t.title, avg(s.salaries) from titles as t join salaries as s where t.emp_no = s.emp_no group by t.title order by avg(s.salaries) asc;