Solved

query to average weekly data

Posted on 2008-10-31
2
223 Views
Last Modified: 2012-05-05
Experts,
I'm trying to create a date parameter query for a line chart that:
1) Based upon the date range create a line chart for each week ending on a Friday where it returns an average for the week. For example, a date range of 6/1/08 - 6/30/08 would return the following:
06/08/08      750
06/13/08      655
06/20/08      600
06/27/08      825
I started with this:

SELECT tblGrossStrokesPerHour.GSPHDate, tblGrossStrokesPerHour.GrossStrokesPerHour, tblGrossStrokesPerHour.LineCode
FROM tblGrossStrokesPerHour
WHERE (((tblGrossStrokesPerHour.GSPHDate) Between [Start Date] And [End Date]) AND ((tblGrossStrokesPerHour.LineCode)=8))
ORDER BY tblGrossStrokesPerHour.GSPHDate;

I attached the a database
 
gsph.zip
0
Comment
Question by:Frank Freese
2 Comments
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
Comment Utility
I didn't have time to try this on your DB. See if this works for you:

SELECT Avg(tblGrossStrokesPerHour.GrossStrokesPerHour) AS AvgOfGrossStrokesPerHour, tblGrossStrokesPerHour.LineCode, Format([GSPHDate],"ww",7) AS WeekNumber, Max([GSPHDate]) AS WeekEnding
FROM tblGrossStrokesPerHour
GROUP BY tblGrossStrokesPerHour.LineCode, Format([GSPHDate],"ww",7)
HAVING (((tblGrossStrokesPerHour.LineCode)=8) AND ((Max([GSPHDate])) Between [Start Date] And [End Date]));

Flyster
0
 

Author Closing Comment

by:Frank Freese
Comment Utility
You nailed it! Many thanks!!!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now