Created
March 21, 2024 03:25
-
-
Save kxzk/b7a61a9aa6962cd4942c934c883c3740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select distinct user_id | |
from events s3 | |
inner join | |
( | |
select distinct user_id | |
from events s2 | |
inner join | |
( | |
select distinct user_id | |
from events | |
where event = 'View Product' | |
and timestamp between '2017-09-01'::timestamp and now() | |
) s1 | |
on s1.user_id = s2.user_id | |
and s2.timestamp < (s1.timestamp + '7 days'::interval) | |
-- and s2.timestamp > s1.timestamp | |
where s2.event = 'Add to Cart' | |
) s2 | |
on s3.user_id = s2.user_id | |
and s3.timestamp < (s2.timestamp + '7 days'::interval) | |
-- and s3.timestamp > s2.timestamp | |
where s3.event = 'Checkout' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment