I have a query that gets the count of products for a customer like this
SELECT top(4)
count([Product]) as p
, Product
FROM CustomerProducts
WHERE CustomerID = '123'
GROUP BY Product
ORDER BY p desc
This works and will give me for instance and will give me for instance
154 Bike
100 Truck
90 Tracktor
80 Buggy
Now I need to get all the customers who have bike in their top 4. I have tried to do this unsuccessfully with a sub query.
SELECT CustomerID
WHERE Product
EXISTS IN {customers top 4 products}
This is the query I am trying to achieve