题解 | #查找在职员工自入职以来的薪水涨幅情况#

查找在职员工自入职以来的薪水涨幅情况

http://www.nowcoder.com/practice/fc7344ece7294b9e98401826b94c6ea5

先确定员工入职时间以及入职时薪水,再确定当前仍然就职的员工薪水,通过两个表的连接查询确定出薪水差值,然后顺序序排序

select t1.emp_no,t2.salary-t1.salary from 
(select employees.emp_no,salary,hire_date from employees, salaries 
where employees.emp_no = salaries.emp_no and employees.hire_date = salaries.from_date) t1
join 
(select employees.emp_no,salary, to_date from employees, salaries 
where employees.emp_no = salaries.emp_no and salaries.to_date = '9999-01-01') t2
on t1.emp_no=t2.emp_no
order by t2.salary-t1.salary ASC
全部评论

相关推荐

shtdbb_:还不错,没有让你做了笔试再挂你
点赞 评论 收藏
分享
评论
1
收藏
分享
牛客网
牛客企业服务