For more information, please refer to: http://blog.csdn.net/fn_2015/article/details/54286366 Below is the sql I wrote myself In the case of the same ranking with the same score: SELECT t.*, ( SELECT count(*) + 1 FROM ( SELECT t1.score FROM t_student_score t1 WHERE 1 = 1 GROUP BY t1.score ) t2 WHERE t2.score > t.score ) AS rank FROM t_student_score t WHERE 1 = 1 ORDER BY t.score desc LIMIT 20