delete from test_table1 a where (a.id,a.cd) in (select id,cd from test_table1 group by id,cd having count(*) > 1) and rowid not in (select min(rowid) from test_table1 group by id,cd having count(*)>1);