数据清理——删除多个字段重复的记录

数据库内容,随机编了一些数据,其中认为两个字段Name、Address1一致为重复记录,保留其中一条

  1. 删除两个字段Name、Address1一致重复的记录,保留一条:
    • 找出
select * from tableabc
where Name in( select Name from tableabc group by Name, Address1 having count(Name) > 1)
    • 删除
1 select * from tableabc 
2 where Name in( select Name from tableabc group by Name, Address1 having count(Name) > 1)
3   and 
4 ID not in(select max(ID) from [mibox].[dbo].[Puzzle] group by Name,Address1 having count(puzzleface) > 1 )

  2. 

猜你喜欢

转载自www.cnblogs.com/healthdata/p/9637399.html