How can I get the position of rows relative to total number of rows based on a field?

Posted by Arms on Stack Overflow See other posts from Stack Overflow or by Arms
Published on 2010-05-11T05:58:53Z Indexed on 2010/05/11 6:04 UTC
Read the original article Hit count: 240

Filed under:
|

I have a scores table that has two fields:

  • user_id
  • score

I'm fetching specific rows that match a list of user_id's. How can I determine a rank for each row relative to the total number of rows, based on score? The rows in the result set are not necessarily sequential (the scores will vary widely from one row to the next). I'm not sure if this matters, but user_id is a unique field.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql