a guest Jul 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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, ,  --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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand