删除重复的记录,只剩下一条
delete from table1
from (select max(c)as cc,a,b from table1 group by a,b having count(*) > 1) as table_1
where (table1.c <> table_1.cc) and (table1.a = table_1.a) and (table1.b = table_1.b)
select id,username into #t from a group by username having count(*)>1
delete from (select * from a where username in(select username from #t)) a where a.id notin (select id from #t)
试试应该好使