Count and display duplicates across multiple fields

Using Oracle 11g I have a table with the following fields:

Name, Type, Link

I want to get a count of the number of duplicates. The definition that this is a duplicate is that the name and type are the same for the two entries, but Ref is different.

I would also like to be able to list records with duplicates (only for one record for each duplicate)

Below will be a duplicate:

Record 1: Name1, Large, 0001
Record 1: Name1, Large, 0002

The following will not duplicate:

Record 1: Name1, Large, 0001
Record 1: Name1, Medium, 0002

+4
source share
1 answer

GROUP BY MAX(ref), /. ref .

HAVING , , / .

select Name, Type, max(Ref)
from tablename
group by Name, Type
having count(*) > 1
+3

Source: https://habr.com/ru/post/1607267/


All Articles