MySQL Rank in the Case of Ties

后端 未结 2 1047
南笙
南笙 2021-01-16 16:40

I need some help dealing with ties when ranking in MySQL. For example:

PLAYER | POINTS

  • Mary: 90
  • Bob: 90
  • Jim: 65
2条回答
  •  不思量自难忘°
    2021-01-16 17:26

    Assuming name is unique

    SELECT t1.name, (SELECT COUNT(*) FROM table_1 t2 WHERE t2.score > t1.score) +1
    AS rnk
    FROM table_1 t1
    

提交回复
热议问题