mysql ranks the second sql statement according to the score

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

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326238079&siteId=291194637