A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

rolling 3 months



 
 
Thread Tools Display Modes
  #21  
Old December 11th, 2008, 01:19 PM posted to microsoft.public.access.queries
buzzmcduffie
external usenet poster
 
Posts: 35
Default rolling 3 months

You guys are wonderful - this works like a gem! thank you !

"John Spencer" wrote:

Try the following. Note the changes in the subquery where I specified TEMP as
the table name. You had

SELECT tblQA_RollingMonths.Task
, tblQA_RollingMonths.EmployeeID
, Count(tblQA_RollingMonths.LoggedMonthYear) AS CountMonths
, Min(tblQA_RollingMonths.LoggedMonthYear) AS PeriodBegin
, Max(tblQA_RollingMonths.LoggedMonthYear) AS PeriodEnd
, Avg(tblQA_RollingMonths.AccuracyScore) AS AvgScore
FROM tblQA_RollingMonths
WHERE tblQA_RollingMonths.LoggedMonthYear In
(SELECT TOP 3 TEMP.LoggedMonthYear
FROM tblQA_RollingMonths as Temp
WHERE TEMP.EmployeeID = tblQA_RollingMonths.EmployeeID
and TEMP.Task = tblQA_RollingMonths.Task
ORDER BY cdate(TEMP.LoggedMonthYear) DESC)
GROUP BY tblQA_RollingMonths.Task
, tblQA_RollingMonths.EmployeeID;


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

buzzmcduffie wrote:
Dale,
I know you are really getting frustrated with me but this help is invaluable
to me!

I must have put the cdate statement in the wrong place because it's still
giving me an average of all dates - not just the last 3 months of data..

SELECT tblQA_RollingMonths.Task, tblQA_RollingMonths.EmployeeID,
Count(tblQA_RollingMonths.LoggedMonthYear) AS NumberOfMonths,
Min(tblQA_RollingMonths.LoggedMonthYear) AS PeriodBegin,
Max(tblQA_RollingMonths.LoggedMonthYear) AS PeriodEnd,
Avg(tblQA_RollingMonths.AccuracyScore) AS AvgScore
FROM tblQA_RollingMonths
WHERE ((([tblQA_RollingMonths].[LoggedMonthYear]) In (SELECT TOP 3
tblQA_RollingMonths.LoggedMonthYear
FROM tblQA_RollingMonths as Temp
WHERE Temp.EmployeeID = tblQA_RollingMonths.EmployeeID and Temp.Task =
tblQA_RollingMonths.Task
ORDER BY cdate(tblQA_RollingMonths.LoggedMonthYear) DESC)))
GROUP BY tblQA_RollingMonths.Task, tblQA_RollingMonths.EmployeeID;

can we spit it up so we first get the last 3 months of data for each and
then query to get the average so I can see what months are produced for each
employee?

Thanks!


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.