find duplicate column within a group

The table below shows 12 records grouped by ID1, ID2 and ID3
The first and second group contain duplicate ID3's within the group.
How can I write a query to find these duplicates.

ID1 ID2 ID3
1   100 A
1   101 A
1   102 B
1   103 C

2      104      A
2      105 B
2      106 B
2   107 C

3      108 A
3   109 B
3   110 C
3   111 D
DaveChoiceTechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike EghtebasDatabase and Application DeveloperCommented:
What database you are working with?
Please improve your sample data by showing duplicates. And, also show sample output.
0
DaveChoiceTechAuthor Commented:
DB2
0
Mike EghtebasDatabase and Application DeveloperCommented:
oh, there are three columns, it seemed two column at first glance:
ID1        ID2       ID3
1            100         A
1            101         A
1            102         B
1            103         C

2            104         A
2            105         B
2            106         B
2            107         C

3            108        A
3            109        B
3            110        C
3            111        D

The values in bold are duplicates and you want to have:

ID1        ID2       ID3
1            100         A
1            102         B
1            103         C

2            104         A
2            105         B
2            107         C

3            108        A
3            109        B
3            110        C
3            111        D

You want distinct ID1_D3  combination. This was not clearly stated. And it is still a guess work.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

DaveChoiceTechAuthor Commented:
My apologies for the lack of clarity to my question. Here is the sample output I am looking for

ID1     ID2       ID3
1        100       A
1        101       A
2        105       B
2         106      B
0
Mike EghtebasDatabase and Application DeveloperCommented:
This works in SQL Server, I hope it will work in DB2 as well:
Select ID1, ID2, ID3
From(Select ID1, ID2, ID3,
     Count(ID3) Over(Partition by ID1, ID3 Order By ID1) cnt
From #T
) As D
Where cnt > 1

Open in new window

Replace #T with your table name. Here is the temp table I used:
Create table #t(ID1 int, ID2 int, ID3 char(1));
Insert into #t(ID1, ID2, ID3) Values
(1, 100, 'A')   --
, (1, 101, 'A') --
, (1, 102, 'B')
, (1, 103, 'C')
, (2, 104, 'A')
, (2, 105, 'B') --
, (2, 106, 'B') --
, (2, 107, 'C')
, (3, 108, 'A')
, (3, 109, 'B')
, (3, 110, 'C')
, (3, 111, 'D');
select * from #t;

Open in new window


Modified...  changed Where cnt=2 to  Where cnt > 1
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulfreelancerCommented:
tiny suggestions, no points please

Select ID1, ID2, ID3
From(Select ID1, ID2, ID3,
     Count(ID3) Over(Partition by ID1, ID3 Order By ID2) cnt
From #T
) As D
Where cnt > 1
Order By ID1, ID2
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.