连续排序,它会为查询出来的每一行记录生成一个序号,依次排序且不会重复,例如1,2,3,4
SELECT names, dept, row_number() OVER(PARTITION BY dept ORDER BY age DESC) rank
FROM workers;
跳跃排序,如果有两个同一级别时,接下来是第三级别,例如1,2,2,4
select names, dept, rank() over(partition by dept order by age desc) rank from workers;
连续排序,如果有两个同一级别时,接下来是第二级别 ,例如1,2,2,3
select names, dept, dense_rank() over(partition by dept order by age desc) rank from workers;
原文:https://www.cnblogs.com/lijwt/p/14051702.html