Created
November 26, 2024 20:05
-
-
Save robisatthefunction/2289b8529944f843398c93f074268dd1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
WITH tbl_events AS ( | |
SELECT e.*, t.exp.experiment_id, t.exp.variation_id | |
FROM events e | |
CROSS JOIN UNNEST(e.experiments) AS t(exp) | |
WHERE t.exp.experiment_id = '24298220083' | |
AND e.entity_id = '24209830080' | |
AND e.timestamp BETWEEN TIMESTAMP '2023-05-18 18:13:00' AND TIMESTAMP '2023-05-25 14:09:10' | |
), | |
dec_tbl AS ( | |
SELECT visitor_id, experiment_id, timestamp | |
FROM decisions | |
WHERE experiment_id = '24298220083' | |
AND timestamp BETWEEN TIMESTAMP '2023-05-18 18:13:00' AND TIMESTAMP '2023-05-25 14:09:10' | |
) | |
SELECT tbl_events.variation_id, | |
COUNT(DISTINCT tbl_events.visitor_id) AS variation_unique_visitors | |
FROM tbl_events | |
JOIN dec_tbl ON tbl_events.visitor_id = dec_tbl.visitor_id | |
AND tbl_events.experiment_id = dec_tbl.experiment_id | |
AND dec_tbl.timestamp < tbl_events.timestamp | |
GROUP BY tbl_events.variation_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment