What I need, is to populate a column with incremental number based on 1 column and the previous rows result.
Will be easier to see it.
Let's says I have the following:
ID_NUM RPT_YR CS
1 1989 0
1 1990 0
1 1991 1
1 1992 1
1 1993 1
I need a column that will increase like so:
ID_NUM RPT_YR CS Increment
1 1989 0 0
1 1990 0 0
1 1991 1 1
1 1992 1 2
1 1993 1 3
1 1994 0 0
1 1995 1 1
This is where it increments based on a value existing in the current row, and increases for each row that contains the value, resetting it's self when the current row is 0 or Null.
Since I don't know exactly how to phrase what I'm asking, I haven't had much luck looking for code for this.
Will be easier to see it.
Let's says I have the following:
ID_NUM RPT_YR CS
1 1989 0
1 1990 0
1 1991 1
1 1992 1
1 1993 1
I need a column that will increase like so:
ID_NUM RPT_YR CS Increment
1 1989 0 0
1 1990 0 0
1 1991 1 1
1 1992 1 2
1 1993 1 3
1 1994 0 0
1 1995 1 1
This is where it increments based on a value existing in the current row, and increases for each row that contains the value, resetting it's self when the current row is 0 or Null.
Since I don't know exactly how to phrase what I'm asking, I haven't had much luck looking for code for this.