【发布时间】:2013-06-17 18:22:44
【问题描述】:
我目前正在处理 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 尝试了一些查询,但我迷路了。
有人能解释一下吗?
非常感谢
【问题讨论】:
-
存款和余额之间的差距总是一个月吗?我们是否可以假设它总是一个月的同一天,即 2 日的存款将有 2 日的余额?
-
不,两个日期之间的间隔可能会有所不同。
标签: sql sql-server-2008 reporting-services ssrs-2008 rdlc