I have some old data that has a structure determined by order. The groups are in ascending order, based that the amount column, and delineated by when the previous value is less than the current value. I just need to assign a unique group ID to each group. This is what I have:
Order Amount Group
1 56
2 63
3 41
4 52
5 59
6 74
7 39
8 42
9 44
10 51
11 62
12 77
and this is what I would like:
Order Amount Group
1 56 1
2 63 1
3 41 2
4 52 2
5 59 2
6 74 2
7 39 3
8 42 3
9 44 3
10 51 3
11 62 3
12 77 3
I can get the previous value with the lag function but am struggling with assigning the number. I am a sql more than pl/sql person. TIA.