Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 5th, 2003, 08:24 AM
tjw tjw is offline
Registered User
 
Join Date: Sep 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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));


 
Old November 12th, 2003, 09:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Without having a very detailed look through your query, couldn't you just have a query that groups by Quarter
eg: GroupBy(DatePart("q", [Sales].[Date]))
and a the Max date in that quarter, then the select the corresponding records?

Steven

I am a loud man with a very large hat. This means I am in charge





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL problem MArk_dB BOOK: Beginning ASP 3.0 1 December 16th, 2007 07:33 AM
sql problem shrisangeeta Classic ASP Databases 2 May 24th, 2006 09:58 AM
SQL Problem pannet1 BOOK: Access 2003 VBA Programmer's Reference 4 April 16th, 2005 10:03 PM
SQL problem Lexus SQL Language 2 January 20th, 2005 09:25 AM
SQL problem Clive Astley Access VBA 4 October 19th, 2004 10:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.