Created
April 6, 2016 19:06
-
-
Save jthandy/0a33350c56dc386d41a0396bda18f068 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
plan_changes as ( | |
select | |
*, | |
lag(total) over (partition by customer order by date_month) as prior_month_total, | |
total - coalesce(lag(total) over (partition by customer order by date_month), 0) as change, | |
lag(period_end) over (partition by customer order by date_month) as prior_month_period_end | |
from invoices | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment