RichardMGreen
Well-known Member
- Joined
- Feb 20, 2006
- Messages
- 2,177
Hi all
I have two queries that work correctly when run separately.
When I try to use them as subqueries to join the two together, they stop working.
Here's the SQL:-
Monthly
This returns zero results for May which is expected.
Year-to-Date
This returns 1 result for this year which is correct.
Now, when I amalgamate the two queries (which gives the following SQL)
I get no results. The 1 from the year-to-date section has disappeared.
I know the two queries are not linked but I haven't linked other queries of similar design and they work OK.
Anyone any ideas?
I have two queries that work correctly when run separately.
When I try to use them as subqueries to join the two together, they stop working.
Here's the SQL:-
Monthly
Code:
SELECT Month([contactDatetime]) AS Month_Number, Count(ext_Contacts.clientId) AS CountOfclientId, ext_Contacts.formOfContact, Year([contactDatetime]) AS [Year]
FROM ext_Contacts
GROUP BY Month([contactDatetime]), ext_Contacts.formOfContact, Year([contactDatetime])
HAVING (((Month([contactDatetime]))=[Month Number]) AND ((ext_Contacts.formOfContact)<>"Telephone" And (ext_Contacts.formOfContact)<>"Email" And (ext_Contacts.formOfContact)<>"Letter") AND ((Year([contactDatetime]))=[Year]));
Year-to-Date
Code:
SELECT Count(ext_Contacts.clientId) AS CountOfclientId, ext_Contacts.formOfContact, Year([contactDatetime]) AS [Year]
FROM ext_Contacts
GROUP BY ext_Contacts.formOfContact, Year([contactDatetime])
HAVING (((ext_Contacts.formOfContact)<>"Telephone" And (ext_Contacts.formOfContact)<>"Email" And (ext_Contacts.formOfContact)<>"Letter") AND ((Year([contactDatetime]))=[Year]));
Now, when I amalgamate the two queries (which gives the following SQL)
Code:
SELECT qry_Monthly_General_F2F.CountOfclientId, qry_YTD_General_F2F.CountOfclientId
FROM qry_Monthly_General_F2F, qry_YTD_General_F2F;
I know the two queries are not linked but I haven't linked other queries of similar design and they work OK.
Anyone any ideas?