This is my table:
Date SSSN MyID Hours
01012013 1234 8
01012013 2345 7
01012013 3456 8
02012013 1234 5
02012013 2345 12
02012013 3456 7
I want to set MyID so that the table looks like this:
Date SSSN MyID Hours
01012013 1234 1 8
01012013 2345 1 7
01012013 3456 1 8
02012013 1234 2 5
02012013 2345 2 12
02012013 3456 2 7
I was looking at this: Syntax of for-loop in SQL Server and this SQL : Update ID; According to Date but didn´t get there.
Seems to be a easy job but somehow not working as desired.
I cannot use alter table IDENTITY(1,1) just to be clear.
This is when using SQL Server.
Solved by using, dense_rank() instead of row_number() as suggested by BlueFeet.