Hello SQL gurus!
I am trying to write a query that will return a set of continguous rows
from a table, and limit the number of rows returned when a maximum
total has been reached by adding a value in one of the columns.
For example, the two columns below represent 2 columns in a table.
a 2
b 2
c 2
d 3
e 4
f 5
g 5
I want to start at, say "c", and return all the rows after it as long
as the sum of the numbers in column 2 (starting at "c") don't exceed
10. The result I'm after would be thus
c 2
d 3
e 4
....because 2 + 3 + 4 = 9 < 10
Any ideas? Many thanks.