Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access 显示更新帐户余额的SQL查询_Ms Access_Ms Access 2007 - Fatal编程技术网

Ms access 显示更新帐户余额的SQL查询

Ms access 显示更新帐户余额的SQL查询,ms-access,ms-access-2007,Ms Access,Ms Access 2007,我在Access数据库中有两个表,[Party]和[Invoice]。我想总结一下所有党派的平衡。以下是我目前的疑问: select Party.AccountCode, Party.AccountDescription, OpeningBalance+sum(invoiceAmount) as balance, invoiceDate from Party,Inovoice where party.accountCode=Inovice.AccountCo

我在Access数据库中有两个表,[Party]和[Invoice]。我想总结一下所有党派的平衡。以下是我目前的疑问:

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
选择
Party.AccountCode,
Party.AccountDescription,
期初余额+总额(发票金额)作为余额,
发票日期
来自聚会,我的声音
其中party.accountCode=Inovice.accountCode
发票日期>=01-01-2013

和invoiceDate使用两个查询。第一个用于计算发票总额,第二个用于计算第三方余额

qrysuming金额:

SELECT 
AccountCode
sum(invoiceAmount) as InvoiceBalance,
FROM Invoice    
group by 
AccountCode,
WHERE invoiceDate>= #01-01-2013#
and invoiceDate<= #30-06-2013#

此查询显示一个您试图纠正的错误,该错误没有将指定的expersion openingBalance+sum(invoiceAmount)作为Agegate functionQuery Working的一部分,但它不会为没有发票的帐户带来任何结果。请将sum(invoiceAmount)更改为nz(sum(invoiceAmount),0。我尝试将sum(invoiceAmount)更改为nz(sum)(invoiceAmount),0)但未成功它显示相同的结果,仅显示在发票表中有记录的人:
其中…invoiceDate
SELECT
Party.AccountCode,
Party.AccountDescription,
OpeningBalance + InvoiceBalance,
from Party LEFT JOIN qrySumInvoiceAmounts
ON party.accountCode=qrySumInvoiceAmounts.AccountCode