日期:2014-05-18 浏览次数:20540 次
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