0

I have been tasked to find all drugs (NDC) within a pharmacy database that are used exclusively by an array of customer IDs but not others. Basically find drugs that have no overlap between customers (array) so that we can trim unneeded inventory used by previous customers. Columns needed are NDC (drug code), DrugName.

Marko Ivkovic
  • 1,262
  • 1
  • 11
  • 14

1 Answers1

0

Hmmm . . .

select NDC, DrugName
from t
group by NDC, DrugName
having sum(case when customerid in ( . . . ) then 1 else 0 end) = 0;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786