同じ c3 のすべての値に対して列 c2 を更新する必要があります。つまり、c3 には 5 つの 0 があり、上位 3 つの 0 には c2 に 10 があります。ここで、レコード 7 と 9 を値 10 で更新する必要があります。最後に、c3 のすべての 0 は同じ c2 値、つまり 10 を持つ必要があります。
2 に答える
How do you want to decide which record to take the value from for updating others?
select c3 from yourTable group by c3
will return your distinct c3 values, now you can get corresponding c2 values fro each of c3, but how do you want to decide which value to use to update others?
Edit:
Few SQL statements approach:
set @uniqueC3s = (select c3 from yourTable group by c3);
-- loop through the resutlset
set @requiredC2Value = (select TOP 1 c2 from yourTable where c3 = @uniqueC3s order by c1);
update yourTable set c2 = @requiredC2Value where c3 = @uniqueC3s;
-- end of loop