0
我在Access數據庫中有兩個表[Party]和[Invoice]。我想總結所有的派對餘額。這裏是我的查詢到目前爲止:用於顯示更新的帳戶餘額的SQL查詢
select
Party.AccountCode,
Party.AccountDescription,
OpeningBalance+sum(invoiceAmount) as balance,
invoiceDate
from Party,Inovoice
where party.accountCode=Inovice.AccountCode
and invoiceDate>=01-01-2013
and invoiceDate<=30-06-2013
group by
Party.AccountCode,
Party.AccountDescription,
invoiceDate
該查詢返回只出現在[發票]表中的雙方的平衡:TOM和JHONS。我想顯示的餘額爲所有4個國家:
這個查詢告訴你試圖在一個錯誤並不inculde指定expersion opensBalance + sum(invoiceAmount)作爲agregate函數的一部分 –
查詢工作但它不會爲沒有發票的帳戶帶來任何結果 –
嘗試將總金額(invoiceAmount)更改爲nz(總和(invoiceAmount),0) –