我用的是ORACLE数据库,不过这跟SQL语句没关系。

解决方案 »

  1.   

    你可以用create table unctr_bak as select distinct * from unctx;
            create table unctr_old as select * from unctx;(将旧的数据保存下来)
           truncate  table unctr;
           insert into table unctx as select * from unctr_bak;
      

  2.   

    DELETE FROM our_table 
    WHERE rowid not in 
    (SELECT MIN(rowid) 
    FROM our_table 
    GROUP BY pkcol);
      

  3.   

    delete from t1 where rowid in
    (select max(rowid) from t1 group by c1,c2,....
     having count(*) > 1 ) 一句话:-) (但是效率是差的)
      

  4.   

    create or replace view v_aa(aa) 
    as 
    select col
    from tables
    group by col;select count(*) from v_aa;有些麻烦,不过可以得到结果。嘿嘿
      

  5.   

    delete from unctx a
    where rowid<(select max(rowid) from unctx where recode=a.recode);
    不过当表较大时(例如:50万),这个方法会叫人难以忍受
      

  6.   

    hosia(红霞飞) 已经把2种方法列出来了!
      

  7.   

    DELETE FROM our_table 
    WHERE rowid not in 
    (SELECT MAX(rowid) 
    FROM our_table 
    GROUP BY record);
    同意bzszp
      

  8.   

    DELETE FROM our_table WHERE rowid not in 
    (SELECT MIN(rowid) FROM our_table GROUP BY pkcol);