A MySQL table looks like this:
Item  Score
-----------
A     3.646
B     2.775
C     6.383
D     0.122
...
There is an index on column Score. I want to select items in the order of descending score, and I also want to know the rank of an item (i.e. the number of that particular row in the result set). In this example, the desired result would be:
Item  Rank
----------
C     1
A     2
B     3
D     4
Is there an efficient way to do this on big tables? I would like to avoid sub-selects if possible.
P.S.: yes, the rank in the result set will of course always be 1, 2, 3, ... but no, I cannot just derive this in the application because these results will be further processed within the DB and not returned to the application.
 
     
    