Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

SQL - Selecione 'n' maiores elementos no grupo

select * from users as t1
where (select count(*) from users as t2
       where t1.division = t2.division and t2.rank > t1.rank) <2
order by division,rank