Skip to content

Instantly share code, notes, and snippets.

@jdwyah
Created June 1, 2017 16:38
Show Gist options
  • Save jdwyah/246d581fca29db0962216a4570ecb53e to your computer and use it in GitHub Desktop.
Save jdwyah/246d581fca29db0962216a4570ecb53e to your computer and use it in GitHub Desktop.
results AS (
SELECT
event,
experiment_test,
experiment_result,
day,
count(DISTINCT first_exposures.tracking_id) exposures,
count(DISTINCT conversions_order_placed_1.tracking_id) order_placed_1,
count(DISTINCT conversions_order_placed_1.tracking_id) /
count(DISTINCT first_exposures.tracking_id) :: FLOAT conversion_rate
FROM first_exposures
LEFT JOIN conversions_order_placed_1
ON first_exposures.tracking_id = conversions_order_placed_1.tracking_id AND
conversions_order_placed_1.created_at > first_exposures.created_at
GROUP BY 1, 2, 3, 4
ORDER BY 1, 2, 3, 4
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment