I'm trying to write a stored procedure to update a field for all rows in a table. I need to pass in a starting value and update all rows for group1 and then increment it by one and update all rows for group2 and so on (the 'groupfield' values won't be in order either). Also, if the groupcount of a group goes over 30 I need to increment by 1 also and continue on.
I have records:
id, groupfield, updatefield
1,1,null
2,7,null
3,1,null
4,5,null
5,2,null
if I start passing '6' for the first value of updatefield I should end up with:
1,1,6
2,7,9
3,1,6
4,5,8
5,2,7
Any help/ideas much appreciated.
I have records:
id, groupfield, updatefield
1,1,null
2,7,null
3,1,null
4,5,null
5,2,null
if I start passing '6' for the first value of updatefield I should end up with:
1,1,6
2,7,9
3,1,6
4,5,8
5,2,7
Any help/ideas much appreciated.