Skip to content

Instantly share code, notes, and snippets.

@henryhund
Created April 13, 2016 19:33
Show Gist options
  • Save henryhund/94b17a40dc18220ee5673eca3ac06ac5 to your computer and use it in GitHub Desktop.
Save henryhund/94b17a40dc18220ee5673eca3ac06ac5 to your computer and use it in GitHub Desktop.
/*
Include Parts 1, 2 and 3
*/
mrr_per_activity AS
( SELECT total_mrr_per_activity.visit_type,
total_mrr_per_activity.visit_details,
total_mrr,
total_count AS total_visits,
round(total_mrr/total_count, 2) AS mrr_per_visit
FROM total_mrr_per_activity
LEFT JOIN count_activities ON total_mrr_per_activity.visit_details = count_activities.visit_details
AND total_mrr_per_activity.visit_type = count_activities.visit_type
ORDER BY mrr_per_visit DESC )
SELECT *
FROM mrr_per_activity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment