Reputation: 1113
I have to find if there are Rows where a Name
has more than one distinct Family
.
Note:
Name
andFamily
can be duplicate.
ID Name Family
1 ABC XYZ
2 DEF XYZ
3 ABC UVW
4 ABC RST
5 DEF RST
6 GHI UVW
The expected Output should be
Name
ABC
DEF
Upvotes: 1
Views: 514
Reputation: 1293
I think you could do this;
SELECT Name, COUNT(DISTINCT Family)
FROM [table]
GROUP BY Name
HAVING COUNT(DISTINCT Family) > 1
Upvotes: 1