我目前正在处理 SSRS 报告,该报告应显示用户定义期间的估计现金流量,例如:提前 1 年
我的表如下所示:
ID DepositDate DepositAmt BalanceDueDate TotalAmount
--------------------------------------------------------
1 02/06/2011 10% 02/07/2011 100
2 16/06/2011 10% 16/07/2011 200
3 08/07/2011 20% 08/08/2011 300
4 15/07/2011 10% 15/08/2011 400
过程
Month Amount
-------------
06 10 (10% (deposit %) of Total amount for ID 1)
06 20 (10% of Total amount for ID 2)
07 90 (balance amount after deposit from previous month for ID 1)
07 180 (balance amount after deposit from previous month for ID 2)
07 60 (20% of Total amount for ID 3)
07 40 (10% of Total amount for ID 4)
08 240 (balance amount after deposit from previous month for ID 3)
08 360 (balance amount after deposit from previous month for ID 4)
预期产出
Month Amount
-------------
06 30
07 370
08 600
用 CTE 尝试了一些查询,但我迷路了。
有人能解释一下吗?
非常感谢