我陷入困境,无法找到与帐户相关的报告我需要在一行中获得贷方帐户和借方帐户。
我的桌子是这样的
Id VoucherId AccountId Amount AccountName IsDebit 1 1 26 100 Sales 0 2 1 10 100 Cash 1 3 2 26 200 Sales 0 4 2 10 200 Cash 1 5 3 10 150 Cash 0 6 3 20 150 Expense A 1 7 4 10 240 Cash 0 8 4 21 240 Expense B 1
而且我需要得到这样的结果
VoucherId DebitName DebitID CreditName CreditID Amount 1 Cash 10 Sales 26 100 2 Cash 10 Sales 26 200 3 Expense a 10 Cash 26 150 4 Expense b 10 Cash 26 240
我尝试过此
select vc.Id, am.Name,vc.AccountName,vd.[Description], case when vd.isdebit=1 then vd.amount else 0 end as C6, case when vd.isdebit=1 then vd.AccountId else 0 end as A, case when vd.isdebit=0 then vd.amount else 0 end as C7, case when vd.isdebit=0 then vd.AccountId else 0 end as B from VoucherDetails vd inner join Voucher Vc on vc.Id=vd.VoucherId and vc.IsDeleted=0 inner join AccountsMaster Am on am.Id=vd.AccountId
以及许多其他查询,但未获得上述结果
请帮助。。在此先感谢
我被困在查找与帐户相关的报表的情况下,我需要在一行中获取贷方帐户和借方帐户。.我的表的金额类似于此Id VoucherId AccountId Amount ...
喜欢吗?:
如果您要重复输入,这将起作用。也就是说,对于每个借项条目,还应该有一个贷项条目。
您需要聚合: