|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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?
|
|
#3
|
|||
|
|||
|
...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... |
|
#4
|
|||
|
|||
|
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 ------------------ |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Ranking Rows |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|