Raised This Month: $32 Target: $400
 8% 

Advanced SQL query problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-15-2006 , 08:03   Advanced SQL query problem
Reply With Quote #1

I have a function which tells the position a player have compared to others when it comes to number of finished maps.

The query below picks steamid and number if finished maps and sorts it with highest number first.

Code:
SELECT steamId,nFinished FROM `skillrank` ORDER BY nFinished DESC
Lets say I want to find out what position a certain player has in that total list.
Example. Queried player = STEAM_y:y:1111111
The result set contains:
STEAM_x:0000000 ; 37
STEAM_x:0000000 ; 30
STEAM_x:0000000 ; 30
STEAM_y:y:1111111 ; 28
STEAM_x:0000000 ; 25
STEAM_x:0000000 ; 24
STEAM_x:0000000 ; 23

The queried player has position 4 of 7.

I get that answer by looping through the result set but do anyone know a query which would return the same info.
Lt Llama is offline
Sandurr
Senior Member
Join Date: Aug 2005
Old 02-15-2006 , 09:30  
Reply With Quote #2

u mean that shows that he's 4th?
Sandurr is offline
Lt Llama
Senior Member
Join Date: Aug 2004
Old 02-15-2006 , 13:25  
Reply With Quote #3

Quote:
Originally Posted by Sandurr
u mean that shows that he's 4th?
Yea, the 4th.
Lt Llama is offline
Fyre
Senior Member
Join Date: Oct 2005
Location: Potsdam/Germany
Old 02-15-2006 , 16:09  
Reply With Quote #4

put a var in your for/while
Code:
new rank = 1 /* 1st row = rank 1 2nd row = rank 2 */ rank++
__________________
Fyre is offline
Send a message via ICQ to Fyre
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

Forum Jump


All times are GMT -4. The time now is 09:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode