Your 6 queries are creating 6 tables (named in the INTO clauses). If you
want them all to go into the SAME table you will need a way to distinguish
which data is which (I added a new column to the front of each query) also
made the second column the same name in each query, you can then use UNION
clause to combine all the queries into one. Something like:
SELECT "CSRV131" As CSType, Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"31") AND
((HEALTHCHECKS.Reviewer1)="CS"));
UNION
SELECT "CSRV231" As CSType, Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"31") AND
((HEALTHCHECKS.Reviewer2)="CS"));
UNION
SELECT "CSRV190" As CSType, Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"90") AND
((HEALTHCHECKS.Reviewer1)="CS"));
UNION
SELECT "CSRV290" As CSType, Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"90") AND
((HEALTHCHECKS.Reviewer2)="CS"));
UNION
SELECT "CSRV1365" As CSType, Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"365") AND
((HEALTHCHECKS.Reviewer1)="CS"));
UNION
SELECT "CSRV2365" As CSType, Count(HEALTHCHECKS.Reviewer2) AS CountOfReviewer
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"365") AND
((HEALTHCHECKS.Reviewer2)="CS"));
You can then create another make table query reading in the above query:
SELECT * FROM AboveQuery INTO [MyTable]
Hope this is something like what you needed.
-Dorian
F0zziebear said:
Query1
SELECT Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer1 INTO [CS RV1 31]
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"31") AND
((HEALTHCHECKS.Reviewer1)="CS"));
Query2
SELECT Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer1 INTO [CS RV2 31]
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"31") AND
((HEALTHCHECKS.Reviewer2)="CS"));
Query3
SELECT Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer1 INTO [CS RV1 90]
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"90") AND
((HEALTHCHECKS.Reviewer1)="CS"));
Query4
SELECT Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer1 INTO [CS RV2 90]
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"90") AND
((HEALTHCHECKS.Reviewer2)="CS"));
Query5
SELECT Count(HEALTHCHECKS.Reviewer1) AS CountOfReviewer1 INTO [CS RV1 365]
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"365") AND
((HEALTHCHECKS.Reviewer1)="CS"));
Query6
SELECT Count(HEALTHCHECKS.Reviewer2) AS CountOfReviewer2 INTO [CS RV2 365]
FROM HEALTHCHECKS INNER JOIN PROJECTS ON HEALTHCHECKS.[Project name] =
PROJECTS.[Project name]
HAVING (((HEALTHCHECKS.[Actual Date]) Between Date() And Date()-"365") AND
((HEALTHCHECKS.Reviewer2)="CS"));
Please note that queries 1,3,5 come from the same column in the table, but
use different date ranges, and the same applies for queries 2,4,6
I then also want to add queries 1&2,3&4,5&6 to create 3 columns which I will
then import into an excel sheet which I use for reporting.
I hope this is enough information, otherwise please ask for more. I am self
taught and therefore have limited knowledge so please try and explain any
IT/techny SQL type language to guide me through.
Many thanks in advance
F0zz
:
Please post the SQL for the six queries
-Dorian
:
I have an excel report which draws data from access. The excel table looks
like this:
Each project is reviewed by two people
Reviewer Name | Reviewer1 | Reviewer2 | Total last 12 months
AA x y x+y
This is repeated for 3 months and 1 month (so the querry uses a date between
to work that out)
x is a create-tabel query and so is y. I want to create one table for these
queries (in total 6 per reviewer) and import that table into excel. I would
also need to add the reviewer 1 and 2 in the table so as to import it in one
go.
Can you help on how to create a table from these six queries, or is there
another way of doing this?
Let me know if you need further clarification