Delete From T Where rowguid not in (Select MID From (Select Min(rowguid) as MID, Max(rowguid) as XID, a, b, c from T Where MID<>XID group by a, b, c) SubS1 Union Select MID From (Select Min(rowguid) as MID, Max(rowguid) as XID, a, b, c from T Where MID=XID group by a, b, c) SubS2)
如果你的rowguid是数字的时候先操作得到有相同的结果集,切这个结果集大于1,就像你上面说的那样a b c rowguid,1 100 25 11111111 100 25 11111121 100 25 1111113就直接删除 大于1111111 这个的就可以delete from TABLE where rowguid>111111 and a='1' and b='100' and c='25'
create table tmp (a, b, c, rowguid)select distinct a, b, c, rowguid() from tablenamedelete from tablenameinsert into tablename(a, b, c, rowguid) select a, b ,c, rowguid() from tmp自己调试一下,用一个临时表,这样清晰简单 select a, b, c from tablename group by a,b,c having count(1)>1这句,可以找出重复的
Delete From Table aWhere Exists (Select 1 from Table b where b.a=a.a and b.b=a.b and b.c=a.c and b.rowid < a.rowID)意思:如果存在abc三个字段和当前记录相同,且rowid小于当前记录的rowid的记录,则删除当前记录。