Delete Duplicates in a table where the table doesnt have any primary keys
By Lalitha Kumaran
Here's a quick tip for deleting duplicate records in a table.
WITH a AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY workid ORDER BY userId) AS RowId FROM tbl1)
delete from a where rowid in (select t.rowid from a t,a t1
where t.userid=t1.userid and t1.rowid>t.rowid)
UserID WorkID
010 444
020 444
010 444
020 444
Delete Duplicates in a table where the table doesnt have any primary keys (544 Views)