I have asked a similar question to this and appologise if you feel you are answering the same question!
I have table with patient treatments. It contains the patient id and the treatment they have had.
create table #TreatmentData(
TreatedWith nvarchar(30) );
There are 7 possible treatments. We can call them A-G.
Patients can have any combination of treatments but i am only interested in those that have had "A" and "C"
So i need to delete all patients that have had any other combination of treatments.
In the table above patient 1 is deleted because he has had treatments A, C and B.
Patient 2 has only had treatments A and C so thats ok.
Patient 3 has had treatment B so is deleted.
Patient 4 has had treatment E so is deleted.
Can someone help with the query?