Hi,
I'm using the following code to find the total sales of each product to each customer, for a user choosen month.
Now this works fine, however, what i really need is to be able to run this query 12 times each time changing the month so i can look at the past 12 months. And feed the results into excel and into a standard report. So i can end up with a table that will enable me to compare one month with another.
ie like the following table
Customer, product, JanTotals, FebTotals, .....DecTotals
I have no idea where to start this, or even it can be automated. Any help would be greatly appreciated.
Alex
I'm using the following code to find the total sales of each product to each customer, for a user choosen month.
Code:
SELECT HistoryHeader.DelAddress01 as Shop, HistoryLines.Description, Sum(HistoryLines.DiscountAmount) AS TotalQty FROM CustomerMaster INNER JOIN (HistoryHeader INNER JOIN HistoryLines ON HistoryHeader.DocumentNumber=HistoryLines.DocumentNumber) ON CustomerMaster.CustomerCode=HistoryHeader.CustomerCode WHERE datepart("m",[HistoryLines.DDate])=[Enter month number Jan=1,feb=2,etc] And Year([HistoryLines.DDate])=Year(Date()) GROUP BY HistoryHeader.DelAddress01,HistoryLines.Description;
ie like the following table
Customer, product, JanTotals, FebTotals, .....DecTotals
I have no idea where to start this, or even it can be automated. Any help would be greatly appreciated.
Alex
Comment