I'm using the following code to find the total sales of each product to each customer, for a user choosen month.
Expand|Select|Wrap|Line Numbers
- 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