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!

Complex query to clean up junk data

b4244a12-3997-4d53-b271-0ba64926a556Aug 19 2019 — edited Aug 20 2019

Somehow a table is having junk data, need to clean it up and generate a new table.

I think it should use case or some row_number over, tried a few, failed. Can you please help ?

original table:

Student Registration Course
John                 CS
John      2018 
John      2017 
Peter     2019      MATH
Mary      2016      MATH

The rule is, if we have duplicate records for a student, merge them together, for Registration, take max of year, so the result will be :

Student Registration Course
John      2018       CS
Peter     2019       MATH
Mary      2016       MATH
Comments
Post Details
Added on Aug 19 2019
8 comments
1,031 views