mysql> select @x := case when @z != c then @x + @y else @x end as rank, @y := case when @z = c then @y + 1 else @y := 1 end as dup, cc as countrycode, @z := c as cnt from (select countrycode as cc, count(1) as c from city group by cc) as t order by c desc;
{{#tags}}- {{label}}
{{/tags}}