Karena CTE tidak dapat diperbarui, Anda perlu merujuk ke tabel asli untuk menghapus baris. Saya pikir Anda sedang mencari sesuatu seperti ini:
WITH ToDelete AS
(
SELECT ID,
ROW_NUMBER() OVER (PARTITION BY lastName, firstName ORDER BY ID) AS rn
FROM mytable
)
DELETE FROM mytable USING mytable JOIN ToDelete ON mytable.ID = ToDelete.ID
WHERE ToDelete.rn > 1;