Created
August 18, 2021 16:47
-
-
Save limata3/243708d8d4f94d48605a3637fb3e5bb7 to your computer and use it in GitHub Desktop.
Ranking customer touchpoints to be used in attribution modelling
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 | |
| customer_id | |
| , touchpoint_id | |
| , lead_id | |
| , order_id | |
| , touchpoint_channel | |
| , touchpoint_campaign | |
| , touchpoint_datetime | |
| , RANK() OVER (PARTITION BY customer_id ORDER BY touchpoint_datetime ASC, rand() ) AS touchpoints_customer_rank_asc /* touchpoint -> customer */ | |
| , RANK() OVER (PARTITION BY customer_id ORDER BY touchpoint_datetime DESC, rand() ) AS touchpoints_customer_rank_des /* touchpoint -> customer */ | |
| , RANK() OVER (PARTITION BY customer_id, lead_id ORDER BY touchpoint_datetime ASC, rand() ) AS touchpoints_customer_lead_rank_asc /* touchpoint -> customer, lead */ | |
| , RANK() OVER (PARTITION BY customer_id, lead_id ORDER BY touchpoint_datetime DESC, rand() ) AS touchpoints_customer_lead_rank_desc/* touchpoint -> customer, lead */ | |
| , RANK() OVER (PARTITION BY customer_id, order_id ORDER BY touchpoint_datetime ASC, rand() ) AS touchpoints_customer_order_rank_asc /* touchpoint -> customer, order */ | |
| , RANK() OVER (PARTITION BY customer_id, order_id ORDER BY touchpoint_datetime DESC, rand() ) AS touchpoints_customer_order_rank_desc /* touchpoint -> customer, order */ | |
| FROM | |
| master_customer_tocuhpoints |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment