Need to edge out the competition for your dream job? Train for certifications today.
GROUP BY CustomerNo
HAVING MIN(Product) IN ('a','b')
AND MAX(Product) IN ('a','b')
Open in new window
SELECT DISTINCT customer_id
orders AS o1
LEFT JOIN orders AS o2
o1.customer_id = o2.customer_id
AND o2.product NOT IN ('A', 'B')
o1.product IN ('A', 'B')
AND o2.customer_id IS NULL;
customer_id IN (
WHERE product IN ('A', 'B')
AND customer_id NOT IN (
WHERE product NOT IN ('A', 'B')
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.