that might work except what i included in this topic is just a sample of a table which has over 20,000 records. so the update needs to cycle through that table and determine which record to place the value and then move to the next single value which fits the criteria and populate the value for the single record of that set. I did a fetch and while fetch == 0 and it took over 2 hours to update records. I can not have that.

i think what you can do is add a logic to generate rownumber based on your group (contractnum, mbd, ybd) and then order by so field. then add a condition rn = 1 to do update for only one record among the group.

1. Your query will not work as you have an ORDER BY in a derived table without a TOP or FOR XML.2. I do not see the point of grouping by quantiy - presumably you want to SUM by quanity.3. Your query is poorly formated and so difficult to maintain.

I would approach the problem as below although, as you have not provided test data in a consumable format, it is difficult to tell.