I am looking for a query that can give me sales invoiced from a given warehouse in the previous 4 weeks separately then a column with an average of the past 4 weeks, so that I am able to recommend how much stock each warehouse should hold on average. Thanks
Hello Mapindu. Try this SQL. Since you asked only for AR Invoices, you will not be able to balance the SQL results with the Sales Analysis Report, but can reconcile with the Inventory Audit Report from the Item Master Data Window.
SUM(T0.Quantity) AS 'Total Invoiced Past 4 Weeks',
(SUM(T0.Quantity))/4 AS 'Total Invoiced Avg per Week'
FROM INV1 T0
INNER JOIN OINV T1
ON T0.DocEntry = T1.DocEntry
DATEDIFF(DAY, T1.DocDate, GETDATE()) <= 28
AND T1.DocType = 'I'