I have a Column 1 which in this case is the same value repeating through all the rows. Column 2 has non distinct rows in which values may repeat. I want to create a column named Group to show that the rows belong to this group in seqential order (Ordered by Column 2). Basically, I need to create an output that looks similar to this:
Column 1 | Column 2 | Group
--------------------------------
100 | AA | 1
100 | AA | 1
100 | AA | 1
100 | BB | 2
100 | BB | 2
100 | CC | 3
100 | DD | 4
100 | DD | 4
You could use the dense_rank function in oracle.
You could use “order by col1, col2” to verify the results.