Simulate rank in mysql (without rank) with two conditions
问题 Coming from this answer: Rank based on two columns I've the following example: CREATE TABLE tmpPoradi (`player` int, `wins` int, `diff` int) ; INSERT INTO tmpPoradi (`player`, `wins`, `diff`) VALUES (1, 10, 12), (2, 8, 2), (3, 10, 10), (4, 8, 1), (5, 8, 7), (6, 10, 14), (8, 10, 10), (7, 12, 3) ; and the desired result must be: +--------+------+------+------+ | player | wins | diff | rank | +--------+------+------+------+ | 7 | 12 | 3 | 1 | | 6 | 10 | 14 | 2 | | 1 | 10 | 12 | 3 | | 3 | 10 | 10