How to get a row rank?

后端 未结 6 1973
一生所求
一生所求 2021-01-05 04:08

HI,

I actually posted similar (or same?) question yesterday, but I thought I need to post a new question since I have short, but clear question.

I have the f

6条回答
  •  梦谈多话
    2021-01-05 04:25

    Just count how many people have more points then them.

    select count(1) from users 
    where point > (select point from users where id = 2) group by point
    

    This will give you the number of people that have more points for the given user. So for user 1 and user 2 the result will be 0 (zero) meaning they are first.

提交回复
热议问题