I was wondering if I could get any help with the following problem.
I have a table of transactions (simplified below) and I only want to select transactions until my
select T1.* from Transactions as T1 where 6 - (select sum(T2.amount) from Transactions as T2 where T2.id <= T1.id ) >= 0 order by id asc
This query works on SQL Server if Postgres supports subqueries like SQL Server does it can help you