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
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
into #t from 表set xact_abort on
begin tran
delete from 表
insert 表 select * from #t
commit tran
drop table #t
select itemno,adjustno from #a where id in
(select max(id) from #a group by itemno) '最新的
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) '最新的
where adjustno
not in
(select adjustno=max(adjustno)
from tablename
group by
itemno)