SQL Problem
I am trying to create a report of sales through time. Listed below is the sql for my query. What I want to do is select the last information for a particular account,brandid in a quarter.
Any suggestions
Tara
SELECT [Vending Accounts].[Ground Number], [MAE Names].[MAE Leisure], Count([Vending Accounts].[Account Number]) AS [CountOfAccount Number], [Vending Accounts].[Account Name], [Sales].[Date], [Sales].[Brand ID], [Company Names].[Company Name], [Brands].[Brand Name], [Sales].[Pack Sales], [Sales].[Number of Weeks], [Pack Sales]/[Number of Weeks] AS Weeklysales, [Vending Accounts].[Comp Sales Info], [Vending Accounts].[Parrys Information], [Vending Accounts].[Live Account]
FROM ([MAE Names] INNER JOIN [Vending Accounts] ON [MAE Names].[Ground Number]=[Vending Accounts].[Ground Number]) INNER JOIN ([Company Names] INNER JOIN (Brands INNER JOIN Sales ON [Brands].[Brand ID]=[Sales].[Brand ID]) ON [Company Names].[Company]=[Brands].[Company]) ON [Vending Accounts].[Account Number]=[Sales].[Account Number]
GROUP BY [Vending Accounts].[Ground Number], [MAE Names].[MAE Leisure], [Vending Accounts].[Account Name], [Sales].[Date], [Sales].[Brand ID], [Company Names].[Company Name], [Brands].[Brand Name], [Sales].[Pack Sales], [Sales].[Number of Weeks], [Vending Accounts].[Comp Sales Info], [Vending Accounts].[Parrys Information], [Vending Accounts].[Live Account]
HAVING (((Sales.[Pack Sales])>0) AND (([Vending Accounts].[Comp Sales Info])=True) AND (([Vending Accounts].[Live Account])=True));
|