There's nothing in mysql that lets you do this directly, but you can hack it in:
SET @prev := null;
SET @cnt := 1;
SELECT name, IF(@prev <> name, @cnt := 1, @cnt := @cnt + 1) AS rank, @prev := name
FROM yourtable
ORDER BY name
This sort of thing is easier done in your client app, using the same basic logic.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…