A
A
Alexander2017-01-14 11:32:56
MySQL
Alexander, 2017-01-14 11:32:56

How to find out the record number in sql query when sorting by some parameter?

There is a user table users in which there is a score field - experience points. You need to sort by this parameter (score) and find where in this sorting the user with some specific id is located (there is an id field in the table). That is, as a result of the request, we should get one number. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2017-01-14
@LordGuard

Where is the user in the rating?
On how many people are in front of him.
select count where score < (select score where id = :curuser)

R
Ravshan Abdulaev, 2017-01-14
@ravshanium

stackoverflow.com/questions/3333665/rank-function-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question