Hi I am trying to obtain the top 3 ranking and pass them to php, and if total score of two ID's are the same, both have the same rank. I tried to use limit 0, 3
and rank()
but only get the the first 3 records without taking same total score into account.
╔════╦════════════╗
║ ID ║ TOTALSCORE ║
╠════╬════════════╣
║ 7 ║ 20 ║
║ 4 ║ 20 ║
║ 6 ║ 18 ║
║ 9 ║ 18 ║
║ 1 ║ 16 ║
╚════╩════════════╝
Then, the ranking should be
╔══════╦════╗
║ RANK ║ ID ║
╠══════╬════╣
║ 1 ║ 7 ║
║ 1 ║ 4 ║
║ 2 ║ 6 ║
║ 2 ║ 9 ║
║ 3 ║ 1 ║
╚══════╩════╝