Last active
February 21, 2018 16:02
-
-
Save RedaAffane/d5386e9d22c36c3b97f2f2a3897dc123 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
SELECT *, | |
CASE WHEN | |
"timestamp" >= "conversion_timestamp" - interval '30 days' | |
AND "timestamp" <= "conversion_timestamp" | |
THEN 1 else 0 END as "keep_touchpoint" | |
FROM( | |
SELECT "conversions".user_id, | |
"conversions".conversion_timestamp, | |
"touchpoints".channel, | |
"touchpoints".timestamp, | |
"conversions".user_id || extract(epoch from "conversions"."conversion_timestamp") AS "macro_user_session" | |
FROM "conversions" "conversions" | |
LEFT JOIN "user_touchpoints" "touchpoints" | |
ON "conversions"."user_id" = "touchpoints"."user_id" | |
) t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment