Group by Month problem

Lanser

Registered User.
Local time
Today, 13:01
Joined
Apr 5, 2010
Messages
60
I have a report (.jpg attached)some data in a table sorted by a couple of queries and I need to list by month and shift I also need to sort it by year but despite mucho searching I haven't been able to do it, so I would be grateful for any pointers/help

here is the record source

Code:
SELECT DISTINCTROW Format$([qryWelfareMshiftTest].[Date],'mmmm yyyy') AS [Date By Month], qryWelfareMshiftTest.Shift, Avg(qryWelfareMshiftTest.Hockburn) AS [Avg Of Hockburn], Avg(qryWelfareMshiftTest.BreastBlisters) AS [Avg Of BreastBlisters], Avg(qryWelfareMshiftTest.GreenLeg) AS [Avg Of GreenLeg], Avg(qryWelfareMshiftTest.BruisedBreast) AS [Avg Of BruisedBreast], Avg(qryWelfareMshiftTest.BruisedWing) AS [Avg Of BruisedWing], Avg(qryWelfareMshiftTest.BrokenWing) AS [Avg Of BrokenWing], Avg(qryWelfareMshiftTest.BruisedLeg) AS [Avg Of BruisedLeg], Avg(qryWelfareMshiftTest.BrokenLeg) AS [Avg Of BrokenLeg], Avg(qryWelfareMshiftTest.Foot_Lesions) AS [Avg Of Foot_Lesions]
FROM qryWelfareMshiftTest
GROUP BY Format$([qryWelfareMshiftTest].[Date],'mmmm yyyy'), qryWelfareMshiftTest.Shift, Year([qryWelfareMshiftTest].[Date])*12+DatePart('m',[qryWelfareMshiftTest].[Date])-1
ORDER BY Year([qryWelfareMshiftTest].[Date])*12+DatePart('m',[qryWelfareMshiftTest].[Date])-1;
 

Attachments

  • screen.jpg
    screen.jpg
    100.2 KB · Views: 177
For Sorting and Grouping in reports you need to do it within the report's SORTING AND GROUPING and not within the query.
 
Hmm I tried doing it via the report and with a rolling year it would sort on the month not on the year so it woul go Jan 2010, Feb 2010 March 2010, April 2009, May 2009 etc
 

Users who are viewing this thread

Back
Top Bottom