Reputation: 2328
I am not asking how to delete duplicates.
I want to assign unique ID for group of duplicates:
A A
A A
A B
B B
B B
A A 1
A A 1
A B 2
B B 3
B B 3
Upvotes: 0
Views: 94
Reputation: 1269503
You are looking for dense_rank()
:
select t.*,
dense_rank() over (order by col1, col2) as newcol
from t;
Upvotes: 2