Techie
Techie

Reputation: 1651

finding the duplicate column depending on the other column

I have 3 columns as

Column1           column2            column3
GU1                 1               a
GU1                 2               a
GU1                 3               a
GU2                 4               b
GU3                 5               c
GU4                 6               a
GU4                 7               b

I would like to filter out the column1 where the values are having multiple column3 values

In this example, I want to pull GU4 where it is having both a & b in the column3.

Upvotes: 0

Views: 44

Answers (1)

juergen d
juergen d

Reputation: 204904

Use distinct in your count

select column1
from your_table
group by column1
having count(distinct column3) = 1

Upvotes: 4

Related Questions