题解 | 使用 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
    )
全部评论

相关推荐

码农索隆:卡学历都不行了,开始卡颜值了
点赞 评论 收藏
分享
05-29 09:02
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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