Rick
I don't understand why it would add hundred to top 10.
I change WHERE Rank <= 10 to WHERE Rank >= 0 and added 52 points it ranked all OK.
Your code worked as expected. With skip a rank and then pick it back up with all 50 that had a tie.
1. first place winner: rank 1
2. tie for second: rank 2
3. tie for second: rank 2 <--
4. next in line (4th place, not 3rd): rank 4 <--
6. etc.
I kind of understand why it ranks that way.
To me it would be interesting to see a tweak.
Going back to O'Reilly ONLamp.com. How to Optimize Rank Data in MySQL
http://onlamp.com/pub/a/mysql/2007/03/01/optimize-mysql-rank-data.htm
Query
USE leaderboard;
set @rank := 0, @pos := 0, @game := null, @score := null;
select gamer, game, score,
greatest(
-- Calculate current row's rank
@rank := if(@game = game and @score = score, @rank, if(@game <> game, 1, @rank + 1)),
-- Save score and game for next row
least(0, @score := score),
least(0, @game := game)) as rank
from score order by game desc, score desc;
leaderboard Query
Ranks in order of 1,2,3,4,5,6, with ties counted ect.
laptop alias:
Your query did drag it locked MYSQL up. Had to end task to get out of query.
Thank you
Tom