34,590
社区成员
发帖
与我相关
我的任务
分享
create table bs(value varchar(1))
insert into bs
select 'a' union all
select 'b' union all
select 'b' union all
select 'c' union all
select 'c' union all
select 'c'
select value from bs
value
-----
a
b
b
c
c
c
-- 执行一次操作后,表变成{b,c,c}
;with t as
( select row_number() over(partition by value order by (select 0)) rn
from bs
)
delete from t where rn=1
select value from bs
value
-----
b
c
c
-- 再执行一次,变成{c}
;with t as
( select row_number() over(partition by value order by (select 0)) rn
from bs
)
delete from t where rn=1
select value from bs
value
-----
c