with DeleteDUplicateinXYZ as ( Select ID, rank()over( order by Id Asc) as [rank] from ppp -----------never use 'partion by' while using rank )Delete from DeleteDUplicateinXYZ where [rank] in (Select id, count([rank]) from DeleteDUplicateinXYZ group by Id having count([rank]) >=2)