от artfulsoftware :
SELECT p1.id, p1.name, COUNT( p2.name ) AS Rank
FROM people p1
JOIN people p2
ON p1.name < p2.name
OR (
p1.name = p2.name
AND p1.id = p2.id
)
GROUP BY p1.id, p1.name
ORDER BY p1.name DESC , p1.id DESC
LIMIT 4,1