回复 2楼 mywisdom88
增加一个主键ID
参考其他人的方法:差别太大了
一、
with m as (
select *, row_number(partition by BB,CC,DD,EE,FF order by id ) rn from test
)
update m
set FF =sign(rn -1)
二、
with T as
(select *,rn=row_number() over (partition by BB,CC,DD,EE order by BB) from A)
update T set FF=case when rn=1 then 0 else 1 end
三、
UPDATE t SET FF=SIGN(rn-1) FROM (select *,rn=row_number() over (partition by BB,CC,DD,EE order by FF) from A) AS t
四、
UPDATE A
SET FF = (CASE WHEN BB = cc AND CC = DD AND DD = EE THEN 0 ELSE 1 END)
select * FROM A