我正在使用 SQL Server 2008。我有一个表AdvanceEntry
。
--------------------------------------------------------------------------------
Code | PaidDate | Amount | ReceiveDate | ReceiveAmount
--------------------------------------------------------------------------------
102 | 15-04-2004 | 3000 | 20-04-2004 | 2000
104 | 23-05-2006 | 1000 | NULL | 0.00
104 | 25-05-2005 | 1500 | 12-06-2005 | 500
当任何人完成贷款时,贷款金额存储在Amount
列中,日期存储在列中PaidDate
,人员代码存储在Code
列中。当该人归还金额时,该金额将存储在 中ReceiveAmount
,日期将存储在 中ReceiveDate
。
现在我想创建一个报告,比如特定代码的分类帐。
例如代码 102
----------------------------------------------------------------------------
PaidDate / ReceiveDate | Amount | ReceiveAmount | Balance
----------------------------------------------------------------------------
15-04-2004 | 3000 | 0 | 3000
20-04-2004 | 0 | 2000 | 1000
对于代码 104
----------------------------------------------------------------------------
PaidDate / ReceiveDate | Amount | ReceiveAmount | Balance
----------------------------------------------------------------------------
23-05-2006 | 1000 | 0 | 1000
25-05-2005 | 1500 | 0 | 2500
12-06-2005 | 0 | 500 | 2000
我怎样才能做到这一点?请帮助我..谢谢