I found a simpliar query that works for me.
But it uses 3 queries. I was wondering if there was a
way to just use one.
qrySumBought:-
SELECT [BookID], [BookType], Sum([QtyBought]) AS SumOfQtyBought
FROM BookBought
GROUP BY [BookID], [BookType];
qrySumSold:-
SELECT [BookID], [BookType], Sum([QtySold]) AS SumOfQtySold
FROM BookSold
GROUP BY [BookID], [BookType];
qryStockOnHand:-
SELECT [Book].[BookID], [Book].[BookType],
nz([SumOfQtyBought])-nz([SumOfQtySold]) AS [Stock On Hand]
FROM (Book LEFT JOIN qrySumBought ON ([Book].[BookID]=[qrySumBought].[BookID]) AND ([Book].[BookType]=[qrySumBought].[BookType])) LEFT JOIN qrySumSold ON ([Book].[BookID]=[qrySumSold].[BookID]) AND ([Book].[BookType]=[qrySumSold].[BookType]);
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.