简体   繁体   中英

MSAccess subdatasheet

I have an Access query, listing invoices and related items in subdatasheet:

SELECT DISTINCTROW OutgoingInvoice.InvoiceID, OutgoingInvoice.Sum, OutgoingInvoice.Complete, Sum(Products.IncomingSUM) AS [Sum Of Products_SUM], [OutgoingInvoice].[Sum]-[Sum Of Products_SUM] AS Különbözet, OutgoingInvoice.Note, OutgoingInvoice.ID
FROM OutgoingInvoice INNER JOIN Products ON OutgoingInvoice.[ID] = Products.[OutgoingInvoice]
GROUP BY OutgoingInvoice.InvoiceID, OutgoingInvoice.Sum, OutgoingInvoice.Complete, OutgoingInvoice.Note, OutgoingInvoice.ID;

The problem, that invoices without items not shown: 在此处输入图像描述 How can I manage to display all the rows from OutgoingInvoice (even if they do not have joined subitem)

SELECT OutgoingInvoice.InvoiceID,
       OutgoingInvoice.Sum,
       OutgoingInvoice.Complete,
       Sum(Products.IncomingSUM) AS [Sum Of Products_SUM],
       [OutgoingInvoice].[Sum]-[Sum Of Products_SUM] AS Különbözet,
       OutgoingInvoice.Note,
       OutgoingInvoice.ID
FROM OutgoingInvoice
LEFT JOIN Products ON OutgoingInvoice.[ID] = Products.[OutgoingInvoice]
GROUP BY OutgoingInvoice.InvoiceID,
         OutgoingInvoice.Sum,
         OutgoingInvoice.Complete,
         OutgoingInvoice.Note,
         OutgoingInvoice.ID;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM