delete from TAB
where z in (select z from TAB group by z having count(z) > 1)
and rowid not in (select min(rowid) from TAB group by z having count(z )>1)
where z in (select z from TAB group by z having count(z) > 1)
and rowid not in (select min(rowid) from TAB group by z having count(z )>1)