G
Guest
Been stuck on this for ages...My problem is, I need to subtract a total of
refunds from a total of purchases within a certain time period from different
suppliers.
So far I have the total purchases by Suppliers using the following sql :
SELECT Purchase.Supplier_ID, Count(Purchase.Stock_ID) AS CountOfStock_ID,
Sum(Stock.[Supplied Price ex-VAT]) AS [SumOfSupplied Price ex-VAT],
Purchase.Date, Sum(Purchase.[Sold Price]) AS [SumOfSold Price]
FROM Supplier INNER JOIN (Stock INNER JOIN Purchase ON Stock.Stock_ID =
Purchase.Stock_ID) ON Supplier.Supplier_ID = Stock.[Supplier_ ID]
GROUP BY Purchase.Supplier_ID, Purchase.Date
UNION SELECT [Supplier_ID], 0, 0, 0, 0
From Supplier
GROUP BY Supplier_ID;
This is to give the cash owed to suppliers.
I need to take out the value of refunded stock within a time frame - Between
Dates.
I have the count/union there as I sometimes there is a refund with no
purchase in a time-frame as vice-versa.
Is there a way? Am I just going about this a long way? HELP!!
refunds from a total of purchases within a certain time period from different
suppliers.
So far I have the total purchases by Suppliers using the following sql :
SELECT Purchase.Supplier_ID, Count(Purchase.Stock_ID) AS CountOfStock_ID,
Sum(Stock.[Supplied Price ex-VAT]) AS [SumOfSupplied Price ex-VAT],
Purchase.Date, Sum(Purchase.[Sold Price]) AS [SumOfSold Price]
FROM Supplier INNER JOIN (Stock INNER JOIN Purchase ON Stock.Stock_ID =
Purchase.Stock_ID) ON Supplier.Supplier_ID = Stock.[Supplier_ ID]
GROUP BY Purchase.Supplier_ID, Purchase.Date
UNION SELECT [Supplier_ID], 0, 0, 0, 0
From Supplier
GROUP BY Supplier_ID;
This is to give the cash owed to suppliers.
I need to take out the value of refunded stock within a time frame - Between
Dates.
I have the count/union there as I sometimes there is a refund with no
purchase in a time-frame as vice-versa.
Is there a way? Am I just going about this a long way? HELP!!