MySQL: Getting a row number (ranking) for a specific row

前端 未结 3 454
刺人心
刺人心 2020-12-31 21:31

I have a users table that has a column called money_sent. I want to order this table by money_sent in descending order, and then find

3条回答
  •  执笔经年
    2020-12-31 21:57

    How about:

    SELECT count(*) FROM users WHERE money_sent < (
        SELECT money_sent FROM users WHERE user = 'joe'
    );
    

提交回复
热议问题