本文介绍了我想获得这些表的总资产总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT 'ASSETS :' AS [Account Name],'Totals:' AS [$]
UNION ALL
SELECT COA.Account_Name AS 'ASSET',CAST(SUM(Debit-Credit)AS varchar)AS [$]
FROM COA JOIN CashBook ON COA.Account_Name = CashBook.Account_Name
WHERE COA.Account_Name IN ('Cash-in- Hand')
GROUP BY COA.Account_Name
UNION ALL
SELECT COA.Account_Name AS 'ASSET',CAST(SUM(Debit-Credit)AS varchar)AS [$]
FROM COA JOIN AccountReceivable ON COA.Account_Name = AccountReceivable.Account_Name
WHERE COA.Account_Name IN ('Account Receivable')
GROUP BY COA.Account_Name
UNION ALL
SELECT COA.Account_Name AS 'ASSET',CAST(SUM(Debit-Credit)AS varchar)AS [$]
FROM COA JOIN Allowance ON COA.Account_Name = Allowance.Account_Name
WHERE COA.Account_Name IN ('Allowance for Doubtful Account')
GROUP BY COA.Account_Name
UNION ALL
SELECT '','------------'
UNION ALL
SELECT 'Total Assets',CAST(SUM(Debit-Credit) AS varchar) AS [$]
FROM COA JOIN CashBook JOIN AccountReceivable JOIN Allowance
ON COA.Account_Name = CashBook.Account_Name JOIN AccountReceivable.Account_Name JOIN Allowance.Account_Name
WHERE COA.Account_Name IN ('Assets')
推荐答案
这篇关于我想获得这些表的总资产总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!