Created
April 13, 2016 19:34
-
-
Save henryhund/c9a218dbd56aa0fcea516c61c19210e5 to your computer and use it in GitHub Desktop.
Part 5/5 of Lead Engagement Scoring Query: https://gist.github.com/henryhund/dc9b2d47c00f018c098c#file-lead_scoring_complete_query-sql
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
/* | |
This is the final part of this query, which gives us leads ordered by aggregate score! | |
Include Parts 1, 2, 3 and 4 | |
*/ | |
SELECT sum(mrr_per_visit) as lead_score, | |
prospect_id | |
FROM all_prospects_visits | |
JOIN mrr_per_activity | |
ON all_prospects_visits.visit_type = mrr_per_activity.visit_type | |
AND all_prospects_visits.visit_details = mrr_per_activity.visit_details | |
GROUP BY prospect_id | |
ORDER BY lead_score DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment