【PostgreSQL】Select取得行号

复制代码
select p1.name
    , (
select count(*)
        
from (
            
select *
            
from persons p2
            
where p2.age  > p1.age
            ) 
as foo
        ) 
+ 1 as rank
from persons p1
order by rank asc;
复制代码
点击右上角即可分享
微信分享提示