Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Select results with only 2 types of products

I need to receive claims (of a customer) who has only specific types of products (productid IN(1,2)). There are different other products but I need only the ones with type 1 and 2 (who would have both at the same time). Client might have other products as well but important to take the ones who have 1&2

Example

clientID claimID productID
 123       333      1
 123       333      2
 123       333      4
 123       333      6
 123       333      7

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

SELECT C.clientID
FROM YOUR_TABLE AS C
WHERE C.productID IN(1,2)
GROUP BY C.clientID
HAVING COUNT(DISTINCT C.productID)=2
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading