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!

Duplicate Values - Selecting One Record Based on Max Value

spalato76Dec 6 2010 — edited Dec 7 2010
Hi All,

I need to run a query that selects one value in a set of duplicates. I'll need to select a record where a column has max value.

So I have 3 columns:

Person_Identifier,
Birth Date,
Primary_Key_column

In my existing table I have some data error issues where a given person has more than one birth date. The data contains multiple years so for one year a birth date was given but in another year the person has a different birth date, usually the days or months are reversed or whatever. I have to take the last recorded birth date and use that record. So I'm taking the max(Primary_Key_column) and selecting the birth date from there. So for example:

Two Records Exist in the Table:

Person_Identifier Birth Date Primary_Key_column Row_No
999999 1999-02-03 500 1
999999 1999-03-02 499 2

So in the case above, I want to be able to select Record #1 (Row_No = 1) because the Primary Key Column is the max value and I want to take the Person_Identifier and Birth Date fields for that record.

Hope this makes sense.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 4 2011
Added on Dec 6 2010
3 comments
2,622 views