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!

delete the duplicate and keep the max records.....

user520824Sep 25 2009 — edited Sep 25 2009
I would like to remove the duplicate records based on columns ID and VAL but keep the max SAL records. ID + VAL is the key in the table and just delete same records by keeping the max sal.

Note: Eventhough there are two records for the same max SAL, just keep one

eg
SQL>  select * from temp_fa;

        ID        VAL        SAL
---------- ---------- ----------
         1        100         10
         1        100         20
         1        100         20
         2        200         10
         3        300         10
         3        300         30
         4        400         10
         4        400         10
         5        500         10
         5        500         20
         5        500         20
         

After deleting the table should looks like

SQL>  select * from temp_fa;

        ID        VAL        SAL
---------- ---------- ----------
         1        100         20
         2        200         10
         3        300         30
         4        400         10
         5        500         20
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2009
Added on Sep 25 2009
7 comments
5,526 views