删除相同的数据如何写?
create table #test
(id int,
badge varchar(20),
num decimal(9,2)
)
insert into #test
select 1,0025,92.5
union all
select 2,0024,92.3
union all
select 3,0023,92.2
union all
select 3,0023,92.2
union all
select 4,0021,92.1
union all
select 5,0020,92.0
union all
select 6,0028,91.1
select * from #test
drop table #test
id badge num
----------- -------------------- -----------
1 25 92.50
2 24 92.30
3 23 92.20
3 23 92.20
4 21 92.10
5 20 92.00
6 28 91.10
其中ID是3的有两条相同的记录,我如果删除其中一条,变成
id badge num
----------- -------------------- -----------
1 25 92.50
2 24 92.30
3 23 92.20
4 21 92.10
5 20 92.00
6 28 91.10
此题之意是只有有两条及两条以上相同,只保留一条,建议只在#test表里删除操作!望赐教!