Skip to content Skip to sidebar Skip to footer

Find A Users Position On A Ordered Sql Table

Is there a way to use the SQL ORDER BY function and then find where a user is on the sorted list as a number My columns are name and score I want to order by score and then find th

Solution 1:

select name, score, 
       @rank := @rank + 1 as rank
from your_table
cross join (select @rank := 0) r
order by score desc

Post a Comment for "Find A Users Position On A Ordered Sql Table"