题解 | SQL211

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

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

select
emp_no
,salary
from salaries
where salary =(SELECT DISTINCT salary
FROM salaries
order by salary desc
limit 1,1 /*查出第二多工资具体数值*/)
order by emp_no 
/*where +子查询*/

select
AA.emp_no
,AA.salary
from 
(select 
emp_no
,salary
,dense_rank()over(order by salary desc) as ra
from salaries) as AA
where AA.ra=2

--from+子查询

全部评论

相关推荐

05-19 19:57
蚌埠学院 Python
2237:Gpa70不算高,建议只写排名,个人技能不在多而在精,缩到8条以内。项目留一个含金量高的,减少间距弄到一页,硕士简历也就一页,本科不要写很多
点赞 评论 收藏
分享
秋盈丶:后续:我在宿舍群里和大学同学分享了这事儿,我好兄弟气不过把他挂到某脉上了,10w+阅读量几百条评论,直接干成精品贴子,爽
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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