How to calculate running total in sql backwards
select id,date,amount,SUM (Amount) OVER (PARTITION BY ID ORDER BY DATE desc) AS runningbalance from sales
I have tried this to reverse running balance going from the most recent to older records. How can I reverse this to go backwards to give me running balance the other way?
from Recent Questions - Stack Overflow https://ift.tt/3FG6YSV
https://ift.tt/eA8V8J
Comments
Post a Comment