Customer_ID Region Location Store_Entry
--------------------------------------------------------
D1 2 Milpitas '2020-10-01' 14:03
D2 5 Santa Clara '2020-10-01' 15:16
D2 5 Santa Clara '2020-10-01' 16:00
D3 4 Milpitas '2020-10-01' 16:12
D1 3 Los Gatos '2020-10-01' 16:23
D2 2 Milpitas '2020-10-01' 17:01
我如何返回那些在访问Milpitas之后访问Santa Clara或在访问#2之后访问#5的客户的customer_id
?
SELECT DISTINCT Customer_ID
FROM table t1
JOIN table t2 USING (Customer_ID)
WHERE t1.Location = 'Santa Clara'
AND t2.Location = 'Milpitas'
AND t1.Store_Entry > t2.Store_Entry