思想:
题目要求统计出当前各个title类型对应的员工当前薪水对应的平均工资。结果给出title以及平均工资avg。首先通过条件t.to_date='9999-01-01'找出当前title类型的员工,其次通过条件s.to_date='9999-01-01'找出员工当前薪水,最后通过条件group by t.title实现以title进行分组便于求平均值。
select t.title,avg(s.salary) from titles t,salaries s
where t.emp_no = s.emp_no and s.to_date='9999-01-01' and t.to_date='9999-01-01' group by t.title;