MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 14th, 2000, 05:15 PM
weldonj weldonj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 41 weldonj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 2 sec
Reputation Power: 8
Let's say I have a list of names and a list of scores. How do I rank these list of names by score? Is it possible to tell somoone that they are tied in 8th place, or could I only count the #of rows theyare ie If they are tied for 8th, but the 11th row listed they'll be listed as 11th?

Thanks,

Weldon

Reply With Quote
  #2  
Old July 15th, 2000, 05:54 AM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
There really isn't any way to account for ties in a ranking using just MySQL. You'll have to pull the records in a query order by the field that you are ranking them on, then use a script to sort thru them to get a ranking allowing for ties. What scripting language are you using?

Reply With Quote
  #3  
Old July 15th, 2000, 09:32 AM
chrris chrris is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Aalborg, Denmark
Posts: 9 chrris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to chrris
...but he can ease the proces a lot using MySQL:

SELECT names FROM table SORT BY score

Depending on your scripting language, you would now pull an array out of the database containing the names sort by score.
Then do a loop that stops when it reaches the relavant name and print the iteration number. In php, it would look like this:

for ($i = 1; $array[$i] != $relavant_name, $i++) {
}
echo $relavant_name . " is on the " . $i . "th place.";

Correct me if I'm wrong...

Reply With Quote
  #4  
Old July 15th, 2000, 09:04 PM
jcbell jcbell is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 14 jcbell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try something like this to get a sort by scores and look at the COUNT(*) values > 1

SELECT names, score FROM table GROUP BY score;

jcbell@magnolia.net

------------------

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Ranking Rows


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway