Guest User

Untitled

a guest
May 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. select user, month, month_2, value_3
  2. from (select t.*,
  3. lead(month, 2) over (partition by user order by month) as month_2,
  4. (sum(value) +
  5. lead(value) over (partition by user order by month) +
  6. lead(value, 2) over (partition by user order by month)
  7. ) as value_3
  8. from t
  9. ) t
  10. where month_2 = add_months(month, 2);
Add Comment
Please, Sign In to add comment