View Full Version : Crosstabbing by week increments


PaulA
03-13-2002, 09:49 AM
Does anyone know how to do a crosstab type count based on weekly increments? The crosstab query wizard does not include this. The week could be based on Sunday - Saturday.

Thanks.

Alexandre
03-15-2002, 12:13 PM
You have to make a first query that will group you data per week. Then base you crosstab query on that first one.

Ex (fairly useless example): Table A stores info on people, namely their birthdate and sex (Female field: boolean).

Query 1:

SELECT Year([BirthDate]) AS BirthYear,
(Day([BirthDate])\7+1) & "/" & Month([BirthDate]) AS BirthWeek,
TableA.Female
FROM TableA;


Query 2:
TRANSFORM Count(Query1.Female) AS ContarDeFemale
SELECT Query1.BirthWeek,
Count(Query1.Female) AS [Total de Female]
FROM Query1
GROUP BY Query1.BirthWeek
PIVOT Query1.BirthYear;


Alex

[This message has been edited by Alexandre (edited 03-15-2002).]