Skip to content

Instantly share code, notes, and snippets.

@jthandy
Created April 6, 2016 19:11
Show Gist options
  • Save jthandy/a2a05d41b5efadcd86773f23f187e620 to your computer and use it in GitHub Desktop.
Save jthandy/a2a05d41b5efadcd86773f23f187e620 to your computer and use it in GitHub Desktop.
news as (
select date_month, sum(total) as value
from data
where revenue_category = 'new'
group by 1
), renewals as (
select date_month, sum(renewal_component_of_change) as value
from data
where revenue_category in ('renewal', 'downgrade', 'upgrade')
group by 1
), prepaids as (
select date_month, sum(total) as value
from data
where revenue_category = 'prepaid renewal'
group by 1
), churns as (
select date_month, sum(total) as value
from data
where revenue_category = 'churn'
group by 1
), upgrades as (
select date_month, sum(change) as value
from data
where revenue_category = 'upgrade'
group by 1
), downgrades as (
select date_month, sum(change) as value
from data
where revenue_category = 'downgrade'
group by 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment