I used the cross tab wizard to create a cross-tab query but it is not quite what I need...
The SQL for this is:
This lists the Pcodes from the My_tbl in each row, and the months in each column but it displays multiple entries of each Pcode for each month.
What I would like for this query to do is display the total number of pcodes (rows) for each month (columns) but I would also like to have the columns filtered into each month of the previous year to create a rolling average cross tab query.
For example, the cross-tab query will display something like the following:
Pcode Jan Feb Mar
------- ----- ----- -----
1 1
1 1
1 1
1 1
1 1
1 1
2 5
and I would prefer:
Pcode Jan08 Feb08 Mar08
----- ----- ----- -----
1 3 2 1
2 5
In standard select queries, I have been able to accomplish this type of ordering with a simple SQL statements as "ORDER BY (Year([Date])*12+Month([Date])-1);" but I am not sure how to do this in the cross-tab query.
Can any one set me straight on this?
thank you
The SQL for this is:
TRANSFORM Count([MY_tbl].ID) AS [Total Of ID]
SELECT [MY_tbl].PCode1
FROM [MY_tbl]
WHERE ((([MY_tbl].[Fail])=1) AND (([MY_tbl].Date) Between [forms]![reports]![StartDate] And [forms]![reports]![EndDate]))
GROUP BY [MY_tbl].PCode1, [MY_tbl].Late, [MY_tbl].[Fail], [MY_tbl].Date
PIVOT Format([Date],"mmm") In ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
This lists the Pcodes from the My_tbl in each row, and the months in each column but it displays multiple entries of each Pcode for each month.
What I would like for this query to do is display the total number of pcodes (rows) for each month (columns) but I would also like to have the columns filtered into each month of the previous year to create a rolling average cross tab query.
For example, the cross-tab query will display something like the following:
Pcode Jan Feb Mar
------- ----- ----- -----
1 1
1 1
1 1
1 1
1 1
1 1
2 5
and I would prefer:
Pcode Jan08 Feb08 Mar08
----- ----- ----- -----
1 3 2 1
2 5
In standard select queries, I have been able to accomplish this type of ordering with a simple SQL statements as "ORDER BY (Year([Date])*12+Month([Date])-1);" but I am not sure how to do this in the cross-tab query.
Can any one set me straight on this?
thank you