sql >> Base de Datos >  >> RDS >> PostgreSQL

Selección de Postgresql hasta alcanzar cierta cantidad total

select id, 
       date, 
       amount, 
       running_total
from (
    select id,
           date,
           amount,
           sum(amount) over (order by date asc) as running_total
    from transactions
) t
where running_total <= 6