题解 | #对所有员工的薪水按照salary降序进行1-N的排名#

对所有员工的薪水按照salary降序进行1-N的排名

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

select s1.emp_no, s1.salary, count(distinct s2.salary) as rank
from salaries as s1, salaries as s2
where s1.salary <= s2.salary and s1.to_date='9999-01-01' and s2.to_date='9999-01-01'
group by s1.emp_no
order by rank

首先需要巩固一下知识点,distinct放在select中使用时,必须放在第一位,统计排名需要用到count()函数。
这题的解题方法,参考了网友的结题答案~

全部评论

相关推荐

迷茫的大四🐶:那你问他上班之后老实了没
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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