题解 | #获取当前薪水第二多的员工的emp_no以及其对应的薪水salary#

获取当前薪水第二多的员工的emp_no以及其对应的薪水salary

http://www.nowcoder.com/practice/8d2c290cc4e24403b98ca82ce45d04db

方法1:

SELECT t3.emp_no ,t3.salary from salaries t3
where t3.salary = ( SELECT t1.salary from salaries t1 GROUP BY t1.salary ORDER BY t1.salary desc LIMIT 1,1 )

方法2:

SELECT t3.emp_no ,t3.salary from salaries t3 where t3.salary = ( SELECT t2.salary from salaries t2 where t2.salary < ( SELECT max(t1.salary) from salaries t1 ) ORDER BY t2.salary desc limit 1 )

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 11:16
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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