# Combining multiple queries

I run the following query on several tables.

``````SELECT DateSerial(Year([TicketDate]), Month([TicketDate]), 1) AS yyyymm, Count(CumulativeSumProblem.TicketNumber) AS CountOfTicketNumber,
(Select Count(*) From CumulativeSumProblem As CS Where
DateSerial(Year(CS.[TicketDate]), Month(CS.[TicketDate]), 1) <= DateSerial(Year(CumulativeSumProblem.[TicketDate]), Month(CumulativeSumProblem.[TicketDate]), 1) ) As CumulativeSum
FROM CumulativeSumProblem
GROUP BY DateSerial(Year([TicketDate]), Month([TicketDate]), 1);
``````

Each table represents a different district/area; and I would like to combine the query results into one big query.

Sometimes I am trying to combine 2 query results, sometimes I combine 3 queries.

How do I go about combing such query results?

Thanks

Ps. this is done in MS Access.
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
If I understand correctly, you want the UNION / UNION ALL operator.  For example, if Region 1 stats are in CumulativeSumProblem and Region 2 stats are in CumulativeSumProblem2:

``````SELECT "Region 1" AS Region, DateSerial(Year([TicketDate]), Month([TicketDate]), 1) AS yyyymm, Count(CumulativeSumProblem.TicketNumber) AS CountOfTicketNumber,
(Select Count(*) From CumulativeSumProblem As CS Where
DateSerial(Year(CS.[TicketDate]), Month(CS.[TicketDate]), 1) <= DateSerial(Year(CumulativeSumProblem.[TicketDate]), Month(CumulativeSumProblem.[TicketDate]), 1) ) As CumulativeSum
FROM CumulativeSumProblem
GROUP BY DateSerial(Year([TicketDate]), Month([TicketDate]), 1)
UNION
SELECT "Region 2" AS Region, DateSerial(Year([TicketDate]), Month([TicketDate]), 1) AS yyyymm, Count(CumulativeSumProblem2.TicketNumber) AS CountOfTicketNumber,
(Select Count(*) From CumulativeSumProblem2 As CS Where
DateSerial(Year(CS.[TicketDate]), Month(CS.[TicketDate]), 1) <= DateSerial(Year(CumulativeSumProblem2.[TicketDate]), Month(CumulativeSumProblem2.[TicketDate]), 1) ) As CumulativeSum
FROM CumulativeSumProblem2
GROUP BY DateSerial(Year([TicketDate]), Month([TicketDate]), 1)
``````

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Yes sir
Commented:
"Yes sir" as in that's what you needed, or something else?

:)
Author Commented:
That's what I needed. Thanks a lot!
Author Commented:
Actually, since I need this data for an MS graph, is there a way you can have the query results be as following:

Date   RegionOne_Sums RegionTwo_Sums.

that way; the date column is a common factor.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.