Given this table
id secId
1 2
2 2
3 2
4 1
5 3
6 3
i would like to add a new column "sortIndex" and init it's values to an ascending int value for each set of equal secId's. So the resulting table would be
id secId sortIndex
1 2 1
2 2 2
3 2 3
4 1 1
5 3 1
6 3 2
So for every set of equal secId's I have a new sequence "1,2,3,4,..." If there is any chance a single query would be just awesome.