I have a table:
**user**
id, name, points
Can you suggest me how to compose a query to get user place by points.
For example:
1, 'David', 5
2, 'Dmitry', 10
3, 'Monica', 15
4, 'Jeniffer', 7
5, 'Andy', 12
User ‘Monica’ has a 1st place based on points, ‘Jeniffer’ – 4th place and so on.
Thanks for advice!
EDIT
I want a query like:
SELECT rank FROM user ... WHERE id = 3;
rank |
1
SELECT rank FROM user ... WHERE id = 5;
rank |
2
Please try the below:
http://sqlfiddle.com/#!2/581fc/9