Thank you for the quick response! I use postgre and it works! Unfortunately the performance is also very slow. I wonder if the inner join causes some kind of n^2 behavior.
Let's said I have a table with an id column and an amount column. I want to select the first n records that adds up to certain amount, say 100. Something similar to the SQL below:
select id, amount from table order by id limit sum(amount) < = 100
Anyway to do it with SQL?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.