Avatar of CarlosScheidecker
 asked on

Listing the number of duplicated records on an Oracle table


I have a table with:

- Name
- Title
- endDate
- Description
- cdate

Name, Title and endDate are the primary key. If one of them is different, than a record is inserted.

However, since date is a timestamp, if I have it some seconds before or after a new record is created.

What I need to know is the duplicated records were Name and Title are exactly the same.

Something like this would only work when you need to deduplicate the values from one field.
I have 2 fields that needs to be exact.

SELECT     tablefield, COUNT(tablefield) AS dup_count
FROM         table
GROUP BY tablefield
HAVING     (COUNT(tablefield) > 1)

I need to diplay the following results per row/tuple :
- Name, Title and the number of occurences that they show if there are duplicates.

If I can determine that the count of Name.Titles being the same is greater than 1, then I have a duplicated record. How can I do that in Oracle?

Oracle DatabaseDatabases

Avatar of undefined
Last Comment

8/22/2022 - Mon

Ah yes, I also have an autoincrement field (ID) that is different and unique for each record.
slightwv (䄆 Netminder)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

- try this:

SELECT     name, title, COUNT(*) AS dup_count
FROM         table
GROUP BY name, title
HAVING     COUNT(*) > 1

Very, very elegant. Need to add that all the selected fields, but the count, must be on the group by clause.

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy