数据库SQL实践16:统计出当前各个title类型对应的员工当前薪水对应的平均工资

思想:

题目要求统计出当前各个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;

猜你喜欢

转载自blog.csdn.net/weixin_43160613/article/details/83714570