Go Back   Forum Care Forums > Development Reference Area > MySQL Discussion

Reply
 
LinkBack Thread Tools Display Modes
position in ordered results
Old
  (#1)
Iain Adams
Guest
 
Posts: n/a
Default position in ordered results - 06-04-2007, 07:58 AM

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

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: position in ordered results
Old
  (#2)
strawberry
Guest
 
Posts: n/a
Default Re: position in ordered results - 06-04-2007, 07:58 AM

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

?

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: position in ordered results
Old
  (#3)
Iain Adams
Guest
 
Posts: n/a
Default Re: position in ordered results - 06-04-2007, 07:58 AM

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.

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: position in ordered results
Old
  (#4)
PeterD
Guest
 
Posts: n/a
Default Re: position in ordered results - 06-04-2007, 07:58 AM

Iain Adams <EMAIL REMOVED> 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
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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

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





Contact Us - Forum Care Forums - Archive - Top