Solved

# query to average weekly data

Posted on 2008-10-31
229 Views
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
Question by:Frank Freese
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 22

Accepted Solution

Flyster earned 500 total points
ID: 22853233
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

ID: 31512152
You nailed it! Many thanks!!!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
###### Suggested Courses
Course of the Month6 days, 23 hours left to enroll