I have a table with the following data:
ID NAME ATTRIBUTE CODE
=============================
1 XX MM GC
1 XX ST GC
2 ZZ LL GC
2 ZZ ST GC
3 AA MM PC
I need the ID, name of from the table which contains either MM Attribute or GC code but not both. Like the query should retrieve the ID numbers only 2 and 3 but not 1 .
How do I do that?
Select Id, Name
From #t
Where (Attribute = 'MM' Or Code = 'GC')
And Id Not In (Select Id From #t
Where (Attribute = 'MM' And Code = 'GC'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With