表A有字段(a,b,c,d,e)其中以e字段为准 有重复记录,现在我想删除重复记录,但同时要留下b字段最大的那笔资料,b为number型!

解决方案 »

  1.   


    delete t from A as t where exists(select * from A where e=t.e and b>t.b)
      

  2.   

    如果你用的是ORACLE数据库系统,可以试一下这个:(hr.ee 为表名的引用,HR为模式,EE为表名)delete from hr.ee where rowid not in
    (
      select rowid from hr.ee t1 where t1.b=
        (
           select max(b) from hr.ee where t1.e=e group by e
        )
    )
      

  3.   

    create table t 
    as
    select n.*
    from (select e,max(b) as b from A group by e) m,A AS n
    where m.e=n.e
    and m.b=n.b
    union
    select * from A where 1=3;
    drop table a;
    rename t to a;
    如果是做数据整理,不是嵌在程序里的话,我都这么写.