jonathanchye
Registered User.
- Local time
- Today, 02:23
- Joined
- Mar 8, 2011
- Messages
- 448
Hi all,
I want to run a query based on one table but with 2 different criterias...
For example here is my table structure (this is actually a query based on a table):
ID
Month No
Month Name
Date Requested
Status
In my query I want to group results into months of a specific year (which I have done fine)
I want then to run a Count of Date Requested where Status = Live vs. Status = Closed
I can't seem to do this in a single query. I have tried showing the table twice in Design view and changed the criteria for my second table (suffix _1) but that doesn't seem to work.
Can anyone perhaps point me in the correct direction?
Below is my SQL code for now:
I want to run a query based on one table but with 2 different criterias...
For example here is my table structure (this is actually a query based on a table):
ID
Month No
Month Name
Date Requested
Status
In my query I want to group results into months of a specific year (which I have done fine)
I want then to run a Count of Date Requested where Status = Live vs. Status = Closed
I can't seem to do this in a single query. I have tried showing the table twice in Design view and changed the criteria for my second table (suffix _1) but that doesn't seem to work.
Can anyone perhaps point me in the correct direction?
Below is my SQL code for now:
Code:
SELECT DISTINCT qryTasksExtendedbyRequestDate.[Month no], qryTasksExtendedbyRequestDate.[Month Name], Count(qryTasksExtendedbyRequestDate.ID) AS CountOfID, Count(qryTasksExtendedbyRequestDate_1.ID) AS CountOfID1
FROM qryTasksExtendedbyRequestDate INNER JOIN qryTasksExtendedbyRequestDate AS qryTasksExtendedbyRequestDate_1 ON (qryTasksExtendedbyRequestDate.Year = qryTasksExtendedbyRequestDate_1.Year) AND (qryTasksExtendedbyRequestDate.[Month Name] = qryTasksExtendedbyRequestDate_1.[Month Name]) AND (qryTasksExtendedbyRequestDate.[Month no] = qryTasksExtendedbyRequestDate_1.[Month no])
WHERE (((qryTasksExtendedbyRequestDate.Year)=2011))
GROUP BY qryTasksExtendedbyRequestDate.[Month no], qryTasksExtendedbyRequestDate.[Month Name]
ORDER BY qryTasksExtendedbyRequestDate.[Month no];