I have multiple values repeated, the value can have status (different or different) or I can have two values with different / differentiated statuses, and I need to make a comparison between them (in this case I use a key). unique that are differentiated and that there can not be the same information in different status. I tried to do this select, but I do not know what might be wrong ...
SELECT * from teste WHERE chave IN (select distinct(chave) from teste group by chave having count(chave) > 1) AND chave NOT IN (select distinct(chave) from teste where status = 'diferente')
EXAMPLE:
KEY | STATUS
ABC123 | DIFFERENTIATED
ABC123 | DIFFERENT
ACB321 | DIFFERENTIATED
ACB321 | DIFFERENT
ACC231 | DIFFERENT - > this data I would like to return