Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Need to delete duplicate entries and retain an original one

Uday_NOct 20 2020

Hi All,
I want to delete duplicate rows (excess rows) and retain only one row.
Query :
CREATE TABLE DUPLICATE_TEST_TAB ( ID NUMBER , FLAG_ID NUMBER , CRE_DT DATE, CRE_USER VARCHAR2(50),CHG_DT DATE,CHG_USER VARCHAR2(50) );

INSERT INTO DUPLICATE_TEST_TAB VALUES (200,1,'20-SEP-2020','John','20-OCT-2020','John');
INSERT INTO DUPLICATE_TEST_TAB VALUES (200,1,'20-SEP-2020','John','20-OCT-2020','John');
INSERT INTO DUPLICATE_TEST_TAB VALUES (200,1,'20-SEP-2020','John','20-OCT-2020','Mike');
INSERT INTO DUPLICATE_TEST_TAB VALUES (200,1,'20-SEP-2020','John','18-OCT-2020','David');

In this i need to delete all rows except 1 and 4 ... I tried using row id but it takes 3rd row as unique as well and deletes only 2nd row . I need to delete 2 nd and 3rd row . Please kind your advice .

Regards,
Uday

This post has been answered by mathguy on Oct 20 2020
Jump to Answer
Comments
Post Details
Added on Oct 20 2020
6 comments
6,738 views