Skip to content

Instantly share code, notes, and snippets.

@jdwyah
Last active November 17, 2015 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdwyah/952d4753418f6c823c74 to your computer and use it in GitHub Desktop.
Save jdwyah/952d4753418f6c823c74 to your computer and use it in GitHub Desktop.
calculated as (select time_period,
case when lag is null then 'NEW'
when lag_size = 1 then 'ACTIVE'
when lag_size > 1 then 'RETURN'
end as this_month_value,
case when (lead_size > 1 OR lead_size IS NULL) then 'CHURN'
else NULL
end as next_month_churn,
count(distinct who_identifier)
from lag_lead_with_diffs
group by 1,2,3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment