题解 | 获取员工其当前的薪水比其manager当前薪水还高的相关信息

获取员工其当前的薪水比其manager当前薪水还高的相关信息

https://www.nowcoder.com/practice/f858d74a030e48da8e0f69e21be63bef

多表连接,一表多用。关键:salary表按照不同列拼接两次,分别得到员工和经理对应的薪水。

select de.emp_no emp_no,m.emp_no manager_no,s1.salary emp_salary,s2.salary manager_salary

from dept_emp de

join dept_manager m on de.dept_no=m.dept_no

join salaries s1 on de.emp_no=s1.emp_no

join salaries s2 on m.emp_no=s2.emp_no

where s1.salary>s2.salary

and de.to_date='9999-01-01'

and m.to_date='9999-01-01'

and s1.to_date='9999-01-01'

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务