position in ordered results

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 ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-24-2007
Iain Adams
 
Posts: n/a
Default position in ordered results

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??

Reply With Quote
  #2 (permalink)  
Old 05-24-2007
strawberry
 
Posts: n/a
Default Re: position in ordered results

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

?

Reply With Quote
  #3 (permalink)  
Old 05-25-2007
Iain Adams
 
Posts: n/a
Default Re: position in ordered results

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.

Reply With Quote
  #4 (permalink)  
Old 05-25-2007
PeterD
 
Posts: n/a
Default Re: position in ordered results

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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:41 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0