With rn AS ( select ROW_NUMBER() over (partition by id) as rn, * from TABLE where condition=1 ), id_list as ( select id from rn where rn.rn > 1 ) delete from TABLE where id in (select id from id_list)