I have a table(Claims) in which I would like to take all records over a certain amount(PdAmt), assign them a random number to use for sorting and then go through the records alternating assigning them to users (update followupuser column value) listed in
another table.
So the process would be:
Select first claim record, assign first user in the table to this claim record
Select second claim record, assign second user in table to second claim record
and so on until all the claims have been assigned.
Also, if the process gets to the end of the user table and there are still more claims to be assigned it needs to start at the beginning of the user table again.
I have figured out how to assign the records a random number but I'm not sure what is the best/efficient method for alternating the assignment(update) between the users. I know I need some kind of looping procedure to iterate through both the list of claims
to be update and also which user to assign to each claim.
Basically my goal is to fairly assign high amount claims between all the users so one doesn't get a bunch of high amount claims.
The update statement would be Update claims set followupuser = @followupuser where claimid = @claimid
I don't have a lot of experience with looping so if someone could help me out with this I would really appreciate it.