The tinyurl for this posting is: http://tinyurl.com/23p4yj3 The question seemed simple: "I want to [to group] rows [so that] the sum of col1 is <= 100." Something like this (I'll fill in the ellipses next):

Note: This is not simply TRUNC'ing the rolling sum of COL1. Frankly, I didn't understand Charles Heilig's query, which used the SQL Model Clause, although I've written about the Model Clausea fewtimesbefore. However, that was a couple of years ago, and it's hardly something I use frequently. So I looked at using the hoary CONNECT BY and 11gR2's recursive CTE (factored subfactor). However, they seem to be limited to the equivalent of the LAG analytic function. Finally, I just built my own solution using the Model Clause: You can see how I "build up" the answer, calculating the RATCHET (cumulative sum for the GRP) and GRP.

Sure, in Oracle I used a CASE statement instead of an IF. And named references instead of "B1", but you can see the affinity between the spreadsheet formula used for most of the RATCHET, e.g: IF((B3+C2)<=100,(B3+C2),B3) and the generalized MODEL formula:

CASE WHEN col1[CV()]+ratchet[CV()-1] <= 100
THEN col1[CV()]+ratchet[CV()-1]
ELSE col1[CV()]
END

Yes, better than a spreadsheet! ************************************************************************************** ENDNOTE: I noticed that posting my query on the original forum posting demonstrated how "+" were getting dropped. Knowing that, I was able to reconstruct Mr. Heilig's MODEL rules if you want to compare his approach: