vendredi 28 août 2015

SQL - Position in statistics

For example, I have table with columns:

playerName TEXT,
score INTEGER

And I have 10,000 rows in this table. Now I can select e.g. top 100 players by using simple SQLite query:

SELECT playerName FROM table ORDER BY score DESC LIMIT 100

And now I have a question: how I can get position in statistics of player X which is not in top100? I can do this by selecting all rows and then in a loop find position of player X but I think it doesn't have a good performance. Is a simpler way to do this in SQLite and MySQL?

Aucun commentaire:

Enregistrer un commentaire