View Full Version : including different queries in a report


jonnycattt
10-09-2001, 05:45 AM
Hello all.
I tried searching the forums for an answer to my question, but I couldn't find precisely what i'm looking for, so forgive me if this has been answered.
Here's what I have: 5 tables, 60 or so records in each table.
I have a query for each of these tables. The query returns aggregate values: the total number of articles we've edited, the total number of print pages, and the average number of print pages of each article.

What I need to do is create a report that shows this aggregate information for each month (each table is a separate month).

So my results would look something like:

January 60 360 6
February 50 250 5
March 60 420 7

and so on....

i looked at the crosstab query help file, and that doesn't seem like what i'm looking for, nor does a union query. I know joins aren't what i'm looking for.

I'd appreciate any help!

Marc

Pat Hartman
10-09-2001, 09:48 AM
Your problem stems from the fact that you have multiple tables where you should have only one. Put all the data into a single table with a date field so you can identify the month of a particular record. Then you can use the following as a model for the SINGLE query that you will need:

Select Format(YourDate,"yyyymm") As YearMonth, Format(YourDate,"mmmm") As MonthName, Count(*) As TotalArticles, Sum(PrintPages) As TotalPrintPages, Avg(PrintPages) As AvgPrintPages
From YourTable
Group By
Format(YourDate,"yyyymm"), Format(YourDate,"mmmm")
Order by Format(YourDate,"yyyymm");

I included year in the group by because at some point you will have data from multiple years in the table. Putting all the data into a single table will enable you to more easily create forms and reports.