1
select ID from table where NewCode = 'A332-PCUBOCSR-HT' group by NewCOde2
delete table where NewCode = 'A332-PCUBOCSR-HT' and
ID <> (select Min(ID) from table where NewCode = 'A332-PCUBOCSR-HT')
保留ID最小的纪录
select ID from table where NewCode = 'A332-PCUBOCSR-HT' group by NewCOde2
delete table where NewCode = 'A332-PCUBOCSR-HT' and
ID <> (select Min(ID) from table where NewCode = 'A332-PCUBOCSR-HT')
保留ID最小的纪录
OR
SELECT *
FROM TABLENAME A
WHERE EXISTS (
SELECT * FROM TABLENAME WHERE NewCode=A.NewCode AND ID<> A.ID)
2.
DELETE A
FROM TABLENAME A
WHERE ID<>(SELECT MIN(ID) FROM TABLENAME WHERE NewCode=A.NewCode)
补充一下,删除语句应该是
delete table where NewCode = 'A332-PCUBOCSR-HT' and
ID not in (select Min(ID) from table where NewCode = 'A332-PCUBOCSR-HT')