snoyes
public text v1 · immutableSELECT customer FROM (
SELECT
*
FROM
products
JOIN (
SELECT t1.customer, t1.date, COUNT(t2.customer) AS theCount
FROM products t1
LEFT JOIN products t2 ON t1.customer = t2.customer AND t1.date < t2.date
GROUP BY t1.customer, t1.date
HAVING theCount < 3
) AS dt USING (customer, date)
HAVING product = 50
) AS dt
GROUP BY customer
HAVING COUNT(*) = 3;