我需要幫助。我有下面的代碼工作正常,但沒有達到我的目標。我想要在減法之前的每一個計算值的列「account_title」,它應該最終給我減去值的差異。感謝預期。帶SELECT,LEFT JOIN和WHERE子句的算術運算符
SELECT
(
SELECT SUM(amount)
FROM mainaccount_a_2017
LEFT JOIN chart_of_account ON (chart_of_account.joint_account_numbers = mainaccount_a_2017.joint_account_number)
LEFT JOIN asset_liability_income_expenditure_tbl ON (asset_liability_income_expenditure_tbl.a_l_code = chart_of_account.account_type)
WHERE a_l_code = 'FA' AND dr_cr_action = 'DR'
)
-
(
SELECT SUM(amount)
FROM mainaccount_b_2017
LEFT JOIN chart_of_account ON (chart_of_account.joint_account_numbers = mainaccount_b_2017.joint_account_number)
LEFT JOIN asset_liability_income_expenditure_tbl ON (asset_liability_income_expenditure_tbl.a_l_code = chart_of_account.account_type)
WHERE a_l_code = 'FA' AND dr_cr_action = 'CR'
)
爲什麼你默默的看着我們?在這裏不適合在全部大寫中輸入你的問題。它使文本更難閱讀,這是粗魯的,它不會幫助你更快。查看主頁面的問題列表 - 您除了您的所有CAPS外還看到了多少個問題?答案:沒有,因爲這樣做不合適。請住手。 –
帳戶標題從哪裏來?您沒有按帳戶對查詢進行分組。 – Barmar
請參閱http://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-查詢 – Strawberry