Created
April 14, 2016 13:05
-
-
Save jthandy/e56a048d89e21140612e5ccdd01ed4ae 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
with events as ( | |
select | |
campaign_id, email_id, sent_date, | |
decode(hard_bounced_date, null, 0, 1) as hard_bounced, | |
decode(first_opened_date, null, 0, 1) as opened, | |
decode(first_clicked_date, null, 0, 1) as clicked, | |
decode(unsubscribed_date, null, 0, 1) as unsubscribed | |
from {{env.schema}}.mailchimp_email_summary | |
) | |
select | |
date_trunc('month', sent_date) as month, | |
count(*) as sends, | |
sum(opened) as opens, | |
sum(clicked) as clicks, | |
avg(opened::float) as open_rate, | |
avg(clicked::float) as click_rate | |
from events | |
group by month | |
order by month |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment