delete 表 where username in 
(select username from 表 group by username having sum(1) > 1)

解决方案 »

  1.   

    select distinct * into #tmp from tablename
    go
    delete from tablename
    go
    insert into tablename 
    select * from #tmp
    go
      

  2.   

    如果是foxpro,select distinct *into table tablename
    from source_tablename 
    若是sql server:select distinct *into  tablename
    from source_tablename
      

  3.   

    delete from tablename where id in 
    (select max(id) from tablename group by username having count(*)>1)
      

  4.   

    delete 你的表 where 编号 not in (select min(编号) from 你的表 group by username having sum(1)>1)
      

  5.   

    如果你的表没有编号:alter table 表 add  编号 int identity(1,1)delete 你的表 where 编号 not in (select min(编号) from 你的表 group by username having sum(1)>1)alter table 表 drop column 编