0
I have several repeated values, the value can have status (different or different) or I can have two values with different/different status, and I need to compare them (in case I use a key), that for this I need to return the exclusives that are differentiated and that there can be the same information in the different status. I tried to make that select, but I don’t know what could 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 that I would like to return
From what I understand you just want to bring the values with status = "DIFFERENT" and that have no key in the status "differentiated"?
– Aprendiz
Post a tablet with 2 fields and 5 values to give an idea of what you call different or differentiated and another with the result you expect.
– Reginaldo Rigo
I changed the post, I do not know if it was clear. Thank you very much for the attention Apprentice and Reginaldo.
– Lucas Yoshida
And if you had two ACC231 records?
– Reginaldo Rigo
It would have to return in the same way, but only if it was in DIFFERENT status. This ACC231 data may be duplicated with the same status.
– Lucas Yoshida
but ACB321 has DIFFERENT status, Voce wants it to return too?
– Aprendiz