itemno               adjustno
03180167      200312150010
03180167      200309150005
03180167      200309090015
03180168      200309090040
03180169      200309090060
03180169      200309070005
03180172      200309060004
03180173      200309260006
03180173      200309060004
03180173      200308120007
03180174      200309090056
03180177      200309070005
03180178      200309060004
03180179      200309090040
03180181      200309260006
03180181      200309060004

解决方案 »

  1.   

    --表中没有主键?select itemno,adjustno=max(adjustno)
    into #t from 表set xact_abort on
    begin tran
    delete from 表
    insert 表 select * from #t
    commit tran
    drop table #t
      

  2.   

    主键就是这两个,用这个Max()是不行的,可能是因为adjunstno是字符字段,所以有好多不是最大的一个。
      

  3.   

    select identity(int,1,1) as id, * into #a from 你的表
    select itemno,adjustno from #a where id in
    (select max(id) from #a group by itemno)     '最新的
      

  4.   

    删除阿
    select identity(int,1,1) as id, * into #a from 你的表
    delete from 你的表
    insert 你的表 select itemno,adjustno from #a where id in
    (select max(id) from #a group by itemno)     '最新的
      

  5.   

    为什么用max不行? 你自己说的要 adjunstno 最大的一个啊,max就是求最大的
      

  6.   

    delete from tablename 
    where adjustno
    not in
    (select adjustno=max(adjustno)
     from tablename 
     group by
      itemno)