https://www.nowcoder.com/practice/b9068bfe5df74276bd015b9729eec4bf?tpId=82&tags=&title=&difficulty=0&judgeStatus=0&rp=1
SELECT emp_no,salary,
dense_rank() over(order by salary desc) t_rank
from salaries
ORDER BY salary desc, emp_no;
SELECT emp_no,salary,
dense_rank() over(partition by left(from_date,4) order by salary desc) t_rank
from salaries
ORDER BY salary desc, emp_no;
https://blog.csdn.net/qq_41057885/article/details/109176014
- 首先,
PARTITION BY
子句使用将结果集划分为分区。 - 其次,
ORDER BY
按salary的序指定了salary的顺序。 - 第三,
DENSE_RANK()
函数应用于具有ORDER BY
子句指定的行顺序的每个分区。