정렬 기준 항목이 안보이네요?
WITH t AS ( SELECT 'aa' gb, 1 seq, 1234 cd FROM dual UNION ALL SELECT 'aa', 2, 1235 FROM dual UNION ALL SELECT 'aa', 3, 9999 FROM dual UNION ALL SELECT 'aa', 4, 1236 FROM dual UNION ALL SELECT 'aa', 5, 2348 FROM dual UNION ALL SELECT 'aa', 6, 3568 FROM dual UNION ALL SELECT 'aa', 7, 9999 FROM dual UNION ALL SELECT 'aa', 8, 1111 FROM dual UNION ALL SELECT 'aa', 9, 9999 FROM dual ) SELECT gb, seq, cd , COUNT(DECODE(cd, 9999, 1)) OVER(PARTITION BY gb ORDER BY seq ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) + 1 grp FROM t ;