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.*,
last_value(past_due_col)
ignore nulls
over(order by id) new_past_due_col
from mytable t
ID | PAST_DUE_COL | new_past_due_col |
---|---|---|
1 | 91 or more days pastdue | 91 or more days pastdue |
2 | null | 91 or more days pastdue |
3 | null | 91 or more days pastdue |
4 | 61-90 days past due | 61-90 days past due |
5 | null | 61-90 days past due |
6 | null | 61-90 days past due |
7 | 31-60 days past due | 31-60 days past due |
8 | null | 31-60 days past due |
9 | 0-30 days past due | 0-30 days past due |
10 | null | 0-30 days past due |
11 | null | 0-30 days past due |
12 | null | 0-30 days past due |