Reputation: 59
Considering that i have the following table:
How i make a query that identify if the same code ( there can be duplicates, no problem with that at all ) have a diferent sex?
Example:
Code Sex
1900 Male
1900 Female
I tried to do a little reseach before questioning here, but couldn't find the solution.
Thanks
Upvotes: 1
Views: 33
Reputation: 527
If I understand correctly what you want is:
Select code,
count(distinct sex) as val
from table
group by code
having val>1
Upvotes: 0
Reputation: 1269643
Here is one method:
select code
from t
group by code
having min(sex) <> max(sex);
Upvotes: 1