buladex Posted July 9, 2010 Share Posted July 9, 2010 i have this table called honor in my sql: id player_id player_name win lose points 26 15098570 Ms.(EviL) 1 0 50 27 15097606 NADA 0 1 0 28 15098570 Ms.(EviL) 1 0 50 29 15096607 ~ABO.MoTa~ 1 0 50 30 15097330 !~!HaSSn!~! 0 1 0 31 15098760 *«EmiäêM»* 1 0 50 32 15097702 ~SworDoFLight~ 0 1 0 33 15098760 *«EmiäêM»* 1 0 50 34 15097378 fager 0 1 0 35 15098760 *«EmiäêM»* 1 0 50 36 15098712 ^kill^TO^live^ 0 1 0 37 15097702 ~SworDoFLight~ 1 0 50 38 15098760 *«EmiäêM»* 0 1 0 39 15094095 ~SwordOfLiGht~ 1 0 50 40 15097702 ~SworDoFLight~ 0 1 0 41 15094095 ~SwordOfLiGht~ 1 0 50 42 15094095 ~SwordOfLiGht~ 0 1 0 43 15098712 ^kill^TO^live^ 1 0 50 and i want to make a rank page for it like this: Rank Name Win Lose 1 ABCD 100 50 2 PROX 99 60 can anyone help me make this???please Quote Link to comment https://forums.phpfreaks.com/topic/207294-sql-ranking/ Share on other sites More sharing options...
Mchl Posted July 9, 2010 Share Posted July 9, 2010 Simplest case: SELECT @rank := @rank+1 AS rank, player_name, win, lose FROM honor CROSS JOIN (SELECT @rank := 0) AS sq ORDER BY win - lose for ex aequo rankings the code is a bit more complicated. You will find several examples when you google for 'MySQL ranking' Quote Link to comment https://forums.phpfreaks.com/topic/207294-sql-ranking/#findComment-1083821 Share on other sites More sharing options...
buladex Posted July 9, 2010 Author Share Posted July 9, 2010 Mchl ur example doesnt make sum from win and lose Quote Link to comment https://forums.phpfreaks.com/topic/207294-sql-ranking/#findComment-1083822 Share on other sites More sharing options...
Mchl Posted July 9, 2010 Share Posted July 9, 2010 Ah.. it wasn't obvoius that it should SELECT @rank := @rank+1 AS rank, h.player_name, h.win, h.lose FROM ( SELECT player_id, player_name, SUM(win) AS win, SUM(lose) AS lose FROM honor GROUP BY player_id ) AS h CROSS JOIN (SELECT @rank := 0) AS sq ORDER BY win - lose Quote Link to comment https://forums.phpfreaks.com/topic/207294-sql-ranking/#findComment-1083826 Share on other sites More sharing options...
buladex Posted July 9, 2010 Author Share Posted July 9, 2010 SELECT player_name, SUM(win) AS win, SUM(lose) AS lose FROM honor GROUP BY player_name better? cuz i dont need player id on rank table thats for serv side only Quote Link to comment https://forums.phpfreaks.com/topic/207294-sql-ranking/#findComment-1083834 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.