最佳答案
没有直接等效的方法,但是您可以使用一些(效率不高)自联接来伪造它.来自collection of MySQL query howtos的一些示例代码:
原文链接:https://www.f2er.com/mysql/531994.htmlSELECT v1.name,v1.votes,COUNT(v2.votes) AS Rank
FROM votes v1
JOIN votes v2 ON v1.votes < v2.votes OR (v1.votes=v2.votes and v1.name = v2.name)
GROUP BY v1.name,v1.votes
ORDER BY v1.votes DESC,v1.name DESC;
+-------+-------+------+
| name | votes | Rank |
+-------+-------+------+
| Green | 50 | 1 |
| Black | 40 | 2 |
| White | 20 | 3 |
| Brown | 20 | 3 |
| Jones | 15 | 5 |
| Smith | 10 | 6 |
+-------+-------+------+