Code
--setup
declare @tb table(k int identity, v char(1))
insert into @tb
select 'a'
union all
select 'b'
union all
select 'a'
union all
select 'c'
union all
select 'd'
union all
select 'e'
union all
select 'd'
--execution
delete
from @tb
where k not in
(
select
(
select top 1 k
from @tb b
where a.v = b.v
)
from @tb as a
group by v
)
--verification
select * from @tb
posted @
2009-07-08 16:45
lp123
阅读(
401)
评论()
编辑
收藏
举报