Reputation: 91
I have one table, in which there can be one or many values to a first column.
If there are multiple same values within first column, I would need to find those, which has at least 2 different values in another column.
Example table CARS:
So, the result of the query would be:
Because there are more honda`s but all of them have the same value of second attribute, I am not interested of those. I need to find only those, which has the same attribute 1 with different attribute 2
Hopefully it`s explained well, if not I can provide more info :)
Thanks
Upvotes: 0
Views: 1107
Reputation: 1269543
You can use exists
:
select t.*
from t
where exists (select 1 from t t2 where t2.car = t.car and t2.color <> t2.color);
Upvotes: 1