add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE mytable(
ID INTEGER NOT NULL PRIMARY KEY
,PAST_DUE_COL VARCHAR(32)
);
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (1,'91 or more days pastdue');
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (2,NULL);
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (3,NULL);
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (4,'61-90 days past due');
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (5,NULL);
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (6,NULL);
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (7,'31-60 days past due');
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (8,NULL);
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (9,'0-30 days past due');
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (10,NULL);
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (11,NULL);
INSERT INTO mytable(ID,PAST_DUE_COL) VALUES (12,NULL);

12 rows affected
select
t.*,
max(past_due_col) over(partition by grp) new_past_due_col
from (
select t.*, count(past_due_col) over(order by id) grp
from mytable t
) t
ID PAST_DUE_COL grp new_past_due_col
1 91 or more days pastdue 1 91 or more days pastdue
2 null 1 91 or more days pastdue
3 null 1 91 or more days pastdue
4 61-90 days past due 2 61-90 days past due
5 null 2 61-90 days past due
6 null 2 61-90 days past due
7 31-60 days past due 3 31-60 days past due
8 null 3 31-60 days past due
9 0-30 days past due 4 0-30 days past due
10 null 4 0-30 days past due
11 null 4 0-30 days past due
12 null 4 0-30 days past due
Warning: Null value is eliminated by an aggregate or other SET operation.