Two Count Queries into One?

XelaIrodavlas

Registered User.
Local time
Today, 21:37
Joined
Oct 26, 2012
Messages
175
Hi all,

(Please forgive my noobiness I am learning every day.) I want to be able to make a query that joins several other queries into one, but in parallel not in one column...

I have used Totals and Count to show the number of records in a table where a certain criteria is true. I have done this for several Tables.

What I want is to have a single query which shows the number of records for all these tables (with their respective criteria in tact). Such that it could then be used to form a report counting all the data.

Here are some examples of the queries i need to join:

SELECT Count([Safety Tours].TourID) AS CountOfTourID
FROM [Safety Tours]
HAVING ((([Safety Tours].Tourdate)<=[Forms]![ReportFormWeeklyMonthly]![DateBox] And ([Safety Tours].Tourdate)>[Forms]![ReportFormWeeklyMonthly]![DateBox]-7));
Which needs to sit next to:

SELECT Count([O2O Reports].O2OID) AS CountOfO2OID
FROM [O2O Reports]
HAVING ((([O2O Reports].DateRecorded)<=[Forms]![ReportFormWeeklyMonthly]![DateBox] And ([O2O Reports].DateRecorded)>[Forms]![ReportFormWeeklyMonthly]![DateBox]-7));

So any ideas?
Thanks in advance :)
 
Not too sure what you mean by "Which needs to sit next to", but since the two Queries seem to have the exact same structure, a UNION Query comes to mind.

Would a UNION Query work for you?
 
Sorry I'm not being clear. In this example I have two tables and I'm asking them (in two separate queries) how many records there are based on a criteria, like this:

No:RecordsinA
------12-------

and,

No:RecordsinB
------09-------


But what I want is a single query that I can make a report from, one that says

No:RecordsinA | No:RecordsinB
------12------|------09------

Can a union query do this? if so how? :)
 
Last edited:
I am a dumb dumb. I can just select other queries to join into one. Like so:

SELECT QueryA.QueryACount, QueryB.QueryBCount
FROM QueryB INNER JOIN QueryA

This certainly seems to do the trick... I'll be back if it doesn't!

Thanks for reading! ;)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom