题解 | #对所有员工的薪水按照salary降序
对所有员工的薪水按照salary降序进行1-N的排名
https://www.nowcoder.com/practice/b9068bfe5df74276bd015b9729eec4bf
---用的两次窗口函数 select---在第一次排序正确的情况再次开启窗口函数,重新把序号更正 t.emp_no, t.salary, dense_rank() over ( partition by t.to_date order by t.salary desc ) t_rank from ( select---第一次窗口函数主要目的是为了按照题目要求排序,但是序号不对 emp_no, salary, to_date, rank() over ( partition by to_date order by salary desc, emp_no asc ) rank_1 from salaries )t 下面的代码排序不对: # select # emp_no, # salary, # to_date, # dense_rank() over ( # partition by # to_date # order by # salary desc, # emp_no asc # ) t_rank # from # salaries