PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

Limite Postgresql per N gruppi

puoi usare funzioni di Windows come dense_rank :

select *,dense_rank()  over (order by  b) group_number from t order by b

così puoi fare :

select * from (
    select *,dense_rank() over (order by  b) group_number  from t order by b
) a where group_number<=2