First time using crosstab query because tired of creating queries and put them together in one query (such a stupid thing to do :D). Not sure how it works still.
I have link table called dbo_Roster to access 2000, I try to group data by Service and dates, for example 01/01 to 01/31 is Jan08, 01/02 to 28/2 is Feb08 and so on. The result should be like below :
[HTML]Service Jan08 Feb08 Mar08 Apr08 May08 Jun08 Total
Service1 # # # # # # #
Service2 # # # # # # #
Service3 # # # # # # #[/HTML]
However, it shows me this only:
[HTML]Service Total Feb08 Jan08
Service1 # # #
Service2 # # #
Service3 # # #[/HTML]
My code is as below:
I think I must have get the crosstab concept wrong. Can anyone show me how to use it correctly?
I have link table called dbo_Roster to access 2000, I try to group data by Service and dates, for example 01/01 to 01/31 is Jan08, 01/02 to 28/2 is Feb08 and so on. The result should be like below :
[HTML]Service Jan08 Feb08 Mar08 Apr08 May08 Jun08 Total
Service1 # # # # # # #
Service2 # # # # # # #
Service3 # # # # # # #[/HTML]
However, it shows me this only:
[HTML]Service Total Feb08 Jan08
Service1 # # #
Service2 # # #
Service3 # # #[/HTML]
My code is as below:
Code:
TRANSFORM Sum([Duration]/12) AS TimeLost SELECT dbo_Roster.[Service Type], Sum([TimeLost]) AS [Total Of TimeLost] FROM dbo_Roster WHERE (((dbo_Roster.[Service Type]) Like "RA*" Or (dbo_Roster.[Service Type]) Like "RA-*")) GROUP BY dbo_Roster.[Service Type] PIVOT IIf(dbo_Roster.Date Between 2008/1/1 And 2008/1/31,"Jan08", IIf(dbo_Roster.Date Between 2008/2/1 And 2008/2/28,"Feb08", IIf(dbo_Roster.Date Between 2008/3/1 And 2008/3/31,"Mar08", IIf(dbo_Roster.Date Between 2008/4/1 And 2008/4/30, "Apr08", IIf(dbo_Roster.Date Between 2008/5/1 And 2008/05/31, "May08", IIf (dbo_Roster.Date Between 2008/6/1 And 2008/6/30, "Jun08"))))));
Comment