How to combine these 2 queries together? (1 Viewer)

Tsung90

Registered User.
Local time
Today, 12:56
Joined
Apr 12, 2012
Messages
23
Hi, I would like to combine 2 queries together but I don't know how to, I've tried for hours, it seems very simple but I cannot do it.

This is the first query:

SELECT Count(*) AS Count_Member_Gym
FROM tblGym
WHERE Ticket_Type='MG';

This is the second query:

SELECT Count(*) AS Count_Nonmember_Gym
FROM tblGym
WHERE (((tblGym.Ticket_Type)='NG'));

The first query is for members of a leisure centre and the second query is for non-members of a leisure centre. I want to be able to produce results to show members and non-members in one query. How do I combine the above together?

Thanks.
 

Tsung90

Registered User.
Local time
Today, 12:56
Joined
Apr 12, 2012
Messages
23
Correction:

The first query is this:

SELECT Count(*) AS Count_Member_Gym
FROM tblGym
WHERE (((tblGym.Ticket_Type)='MG')) AND (((tblGym.Date_Gym) Between '02/01/12' And '04/01/12'));

The second query is this:

SELECT Count(*) AS Count_Nonmember_Gym
FROM tblGym
WHERE (((tblGym.Ticket_Type)='NG')) AND (((tblGym.Date_Gym) Between '02/01/12' And '04/01/12'));
 
Local time
Today, 21:56
Joined
Aug 8, 2010
Messages
245
SELECT tblGym.TicketTypeID, Count(tblGym.TicketTypeID) AS CountOfTicketTypeID
FROM tblGym
GROUP BY tblGym.TicketTypeID, tblGym.GymDate
HAVING (((tblGym.GymDate) Between #02/01/12# And #04/01/12#))

This will look like:

TicketTypeID Count
MG 25
NG 10
 
Local time
Today, 21:56
Joined
Aug 8, 2010
Messages
245
Just realized there may be other ticket types, so use:

SELECT tblGym.TicketTypeID, Count(tblGym.TicketTypeID) AS CountOfTicketTypeID
FROM tblGym
GROUP BY tblGym.TicketTypeID, tblGym.GymDate
HAVING (((tblGym.TicketTypeID)="MG" Or (tblGym.TicketTypeID)="NG") AND ((tblGym.GymDate) Between #1/2/2012# And #1/4/2012#));
 

Users who are viewing this thread

Top Bottom