本文介绍了请帮我解决这个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 ID日期参考账户_代码账户_名称详情借方贷方余额 1 2013-04-19 NULL 1003应收账款ffrew 2000 0 2000 2 2013-04-19 NULL 1003应收帐款wwrt 0 1000 1000 这是我上面显示的表格样本,我想要总共3个表格作为总资产 这是我的代码如下: IDDateRefAccount_CodeAccount_NameDetailsDebitCreditBalance12013-04-19NULL1003Account Receivableffrew20000200022013-04-19NULL1003Account Receivablewwrt010001000This is the sample of my tables shown above and i want the total of the 3 tables as total assetsand this is my code below:SELECT 'ASSETS :' AS [Account Name],'Totals:' AS [$]UNION ALLSELECT COA.Account_Name AS 'ASSET',CAST(SUM(Debit-Credit)AS varchar)AS [$]FROM COA JOIN CashBook ON COA.Account_Name = CashBook.Account_NameWHERE COA.Account_Name IN ('Cash-in- Hand')GROUP BY COA.Account_NameUNION ALLSELECT COA.Account_Name AS 'ASSET',CAST(SUM(Debit-Credit)AS varchar)AS [$]FROM COA JOIN AccountReceivable ON COA.Account_Name = AccountReceivable.Account_NameWHERE COA.Account_Name IN ('Account Receivable')GROUP BY COA.Account_NameUNION ALLSELECT COA.Account_Name AS 'ASSET',CAST(SUM(Debit-Credit)AS varchar)AS [$]FROM COA JOIN Allowance ON COA.Account_Name = Allowance.Account_NameWHERE COA.Account_Name IN ('Allowance for Doubtful Account')GROUP BY COA.Account_NameUNION ALLSELECT '','------------'UNION ALLSELECT 'Total Assets',CAST(SUM(CashBook.Debit- CashBook.Credit+ AccountReceivable. Debit- AccountReceivable.Credit+ Allowance.Debit-Allowance.Credit) AS varchar) AS [$]FROM COA JOIN CashBook ON COA.Account_Name = CashBook.Account_Name JOIN AccountReceivable ON COA.Account_Name = AccountReceivable.Account_Name JOIN Allowance ON COA.Account_Name = Allowance.Account_NameWHERE COA.Account_Name_Cate IN ('Assets') 推荐答案 这篇关于请帮我解决这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-19 02:22