题解 | 使用 count 获取第二高的工资

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

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


select 
s.emp_no ,
s.salary ,
(select last_name from employees e where e.emp_no = s.emp_no) last_name,
(select first_name from employees e where e.emp_no = s.emp_no) first_name

from
salaries s
where
s.salary = 
(
select 
a.salary
from
salaries a , salaries b
where
a.emp_no <> b.emp_no
and a.salary < b.salary
group by a.salary
having count(a.salary) = 1
    )
全部评论

相关推荐

06-26 18:30
门头沟学院 Java
据说名字越长别人越关注你的昵称我觉得我要被关注了:你问问这里面有多少是正经候选人,而不是乱打招呼的
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-23 18:33
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-24 20:25
腾讯今年实习招了这么多人,后面秋招还会招人吗??想着秋招再战来着
牛客965593684号:腾讯好像2020年之后就是实习生招得多,应届生基本上不招,纯实习转正
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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