clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36247 in the last week).

create table t (a, b) as select 'A', 3 from dual union all select 'B', 7 from dual union all select 'C', 6 from dual union all select 'D', 5 from dual union all select 'E', 9 from dual union all select 'F', 3 from dual union all select 'G', 8 from dual;
7 rows affected
 hidden batch(es)


SELECT a, b, rolling_sum, bin_num FROM t MATCH_RECOGNIZE ( ORDER BY a MEASURES SUM(b) rolling_sum, MATCH_NUMBER() AS bin_num ALL ROWS PER MATCH AFTER MATCH SKIP PAST LAST ROW PATTERN (A+) DEFINE A AS SUM(b) < 15 + A.b)
A B ROLLING_SUM BIN_NUM
A 3 3 1
B 7 10 1
C 6 16 1
D 5 5 2
E 9 14 2
F 3 17 2
G 8 8 3
 hidden batch(es)