Re: What's wrong with this query?
- From: John Spencer <spencer@xxxxxxxxxx>
- Date: Sat, 07 Apr 2007 13:27:47 -0400
Because your subquery in the where clause only returns the Max date for the entire table.
You might be better off building a query to give you the Max date for every client and adding that to your query. You could also try using a coordinated subquery- this could be fairly slow.
SELECT tblClient_Income_History_DateV1.ClientID, qryClientNameV3.ClientName,
Sum(tblClient_Income_HistoryV1.Cl_Mo_Inc_Source_Amt) AS
SumOfCl_Mo_Inc_Source_Amt
FROM (tblClient_Income_History_DateV1 INNER JOIN tblClient_Income_HistoryV1
ON tblClient_Income_History_DateV1.ClMoIncDateID =
tblClient_Income_HistoryV1.ClMoIncDateID) INNER JOIN qryClientNameV3 ON
tblClient_Income_History_DateV1.ClientID = qryClientNameV3.ClientID
WHERE (((tblClient_Income_History_DateV1.Cl_Mo_Inc_Date)=
(Select Max(Cl_Mo_Inc_Date)
From tblClient_Income_History_DateV1 as T3
WHERE T3.ClientID = tblClient_Income_History_DateV1.ClientID )))
GROUP BY tblClient_Income_History_DateV1.ClientID, qryClientNameV3.ClientName;
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
shep wrote:
ACCESS 2003.
I want to create list of all clients with date of last income change. I am getting only the client with last date rather than all clients. Why?
SELECT tblClient_Income_History_DateV1.ClientID, qryClientNameV3.ClientName, Sum(tblClient_Income_HistoryV1.Cl_Mo_Inc_Source_Amt) AS SumOfCl_Mo_Inc_Source_Amt
FROM (tblClient_Income_History_DateV1 INNER JOIN tblClient_Income_HistoryV1 ON tblClient_Income_History_DateV1.ClMoIncDateID = tblClient_Income_HistoryV1.ClMoIncDateID) INNER JOIN qryClientNameV3 ON tblClient_Income_History_DateV1.ClientID = qryClientNameV3.ClientID
WHERE (((tblClient_Income_History_DateV1.Cl_Mo_Inc_Date)=(Select Max(Cl_Mo_Inc_Date) From tblClient_Income_History_DateV1)))
GROUP BY tblClient_Income_History_DateV1.ClientID, qryClientNameV3.ClientName;
Thanks for help
- Follow-Ups:
- Re: What's wrong with this query?
- From: shep
- Re: What's wrong with this query?
- Prev by Date: criteria HELP!!!!!!!!!!!!!!!!!!!!!
- Next by Date: Date range for a query
- Previous by thread: Re: What's wrong with this query?
- Next by thread: Re: What's wrong with this query?
- Index(es):
Relevant Pages
|