I\'m having trouble coming up with a query that will find all customers who have purchased both PROD1 and PROD2.
Here\'s a pseudo-query that kind of looks like what
SELECT COUNT(DISTINCT userId)
FROM(
SELECT userId
FROM transactions
WHERE product = 'PROD1'
INTERSECT
SELECT userId
FROM transactions
WHERE product = 'PROD2');
The query creates two intermediate tables, one which contains userId of customer who bought PROD1 and another identical table for those who bought PROD2. The intersection operator returns a table which contains only rows found in both previous tables, i.e those who bought both products.