日期:2014-05-17 浏览次数:20541 次
;WITH MU AS (
SELECT F1,F2,F3,ROW_NUMBER() OVER(ORDER BY F1 ASC) AS NUM
FROM TB
)
UPDATE T2 SET
T2.F2=CASE WHEN T2.F2=(T1.F2+T3.F2)/4 THEN (T1.F2+T3.F2)/2 ELSE T2.F2 END
,T2.F3=CASE WHEN T2.F3=(T1.F3+T3.F3)/4 THEN (T1.F3+T3.F3)/2 ELSE T2.F3 END
FROM MU T1
INNER JOIN MU T2 ON T1.NUM=T2.NUM-1
INNER JOIN MU T3 ON T2.NUM=T3.NUM-1
WHERE (T2.F2=(T1.F2+T3.F2)/4 OR T2.F3=(T1.F3+T3.F3)/4)