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

Seleziona Postgresql fino al raggiungimento di un determinato importo totale

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