This is a discussion on position in ordered results within the MySQL Database forums, part of the Database Forums category; Hi, I have a table with some ranks in. Firstly I want to order the table by the ranks. Then ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On May 24, 5:22 pm, Iain Adams <aca04...@shef.ac.uk> wrote:
> Hi, > > I have a table with some ranks in. Firstly I want to order the table > by the ranks. Then I want to search the new ordered table to find out > the position of a specific row with a specific rank. Is this possible?? but won't that just be equal to the rank: id rank 1 4 2 5 3 3 4 1 5 2 SELECT * FROM table ORDER BY rank 4 1 5 2 3 3 1 4 2 5 ? |
|
|||
|
On 24 May, 17:26, strawberry <zac.ca...@gmail.com> wrote:
> On May 24, 5:22 pm, Iain Adams <aca04...@shef.ac.uk> wrote: > > > Hi, > > > I have a table with some ranks in. Firstly I want to order the table > > by the ranks. Then I want to search the new ordered table to find out > > the position of a specific row with a specific rank. Is this possible?? > > but won't that just be equal to the rank: > > id rank > 1 4 > 2 5 > 3 3 > 4 1 > 5 2 > > SELECT * FROM table ORDER BY rank > > 4 1 > 5 2 > 3 3 > 1 4 > 2 5 > > Not quite because the ranking refers to a world ranking scale. Thus the ranks actually are values from around 1000 to 3000, these aren't ranks exactly but are a kind of score that person has. So I need to find, the rank of that person out of all the people in the table. |
|
|||
|
Iain Adams <aca04iba@shef.ac.uk> wrote:
> I have a table with some ranks in. Firstly I want to order the table > by the ranks. Then I want to search the new ordered table to find out > the position of a specific row with a specific rank. Is this possible?? select count(*) from table where rank < (rank of specific person) -- Pd |
![]() |
| Thread Tools | |
| Display Modes | |
|
|