转:SQL重复记录查询
2011-03-09 10:55
429 查看
select distinct * into #Temp from RepeatAll
drop table RepeatAll
select * into RepeatAll from #Temp
drop table #Temp
select identity(int,1,1) id,* into #Temp from RepeatAll
drop table RepeatAll
--select
select name,sex,address from #Temp group by name,sex,address having (count(*)>1)
--delete
delete from #Temp where id not in
(select min(id) id from #Temp group by name,sex,address)
select name,sex,address into RepeatAll from #Temp
drop table #Temp
drop table RepeatAll
select * into RepeatAll from #Temp
drop table #Temp
select identity(int,1,1) id,* into #Temp from RepeatAll
drop table RepeatAll
--select
select name,sex,address from #Temp group by name,sex,address having (count(*)>1)
--delete
delete from #Temp where id not in
(select min(id) id from #Temp group by name,sex,address)
select name,sex,address into RepeatAll from #Temp
drop table #Temp
相关文章推荐
- SQL查询 重复记录
- 查询重复记录的SQL语句
- sql记录去重(SQL查询或者删除表中重复记录)
- sql 查询去除重复记录
- SQL操作语句之查询及删除重复记录的方法
- sql查询重复记录、删除重复记录方法大全
- sql查询重复记录、删除重复记录方法大全
- 查询同一表内多字段同时重复记录的SQL语句
- SQL语句查询数据库中重复记录的个数
- **SQL某一表中重复某一字段重复记录查询与处理
- sql查询重复记录、删除重复记录方法大全
- 查询及删除重复记录的SQL语句
- SQL查询重复记录
- SQL查询和删除重复记录
- SQL重复记录查询
- 查询及删除重复记录的SQL语句
- SQL查询重复记录的办法
- SQL查询多条不重复记录值简要解析【转载】
- SQL面试常见问题处理:查询和删除重复记录
- SQL查询重复记录的办法