Wednesday, April 18, 2007

-- Query to delete the duplicate rows in a table (without primary key)
DELETE FROM empWHERE ROWID NOT IN
(SELECT MIN(ROWID) FROM emp GROUP BY A, B)

Delete from empwhere rowid in (select idfrom (select rowid id,Row_number()
over(partition by A, B order by SAL asc) top1FROM emp)where top1 > 1)

No comments: