Say we have the following SQL Server table
date, qty, debit
I want to calculate a NewDebit value based on the formula shown here. I have tried everything - grouping, partition, cte - it is just not happening...
Anything I try is either a recursive CTE, or partition by, it seems I can't get the previous sum of the calculated results.

See example
Output is
with test data