I have data as below (first 3 columns). I would like to create the 4th column - newstatus
.
Logic for the newstatus
column is that
- for each pk2
- if column
status
is blank then pull value from the most recent row wherestatus
is either new or old.
Because of that row 3 gets value new which is from row 2 while row 9 gets value old from row 7. row 8 is ignored because it has value ignore
pk status pk2 newstatus
1 1
2 new 1
3 1 new
4 ignore 1
5 ignore 1
6 2
7 old 2
8 ignore 2
9 2 old
10 new 2