Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. Select
  2. Customer_ID
  3. ,row_number() over (partition by Customer_ID order by date) r_num
  4. ,date
  5. ,total_paid
  6. Into #Customer_Transactions
  7. From Customer_Transactions
  8. Select
  9. t1.Customer_ID
  10. ,datediff(dd,t1.date ,t2.date) --this will calculate the difference in days
  11. From #Customer_Transactions t1
  12. Join #Customer_Transactions t2
  13. ON t1.Customer_ID = t2.Customer_ID
  14. And t1.r_num = t2.r_num+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement