Thanks, Ken
An ancillary problem, to produce a query that lists the max items for
each
item in another field.
I have a Select query that lists, among other things, two fields:
ID_Clients
EndDate
Each entry in ID_Clients may be listed several times
I want to generate a Select query based on the above query that lists
each
value of ID_Clients just once, by selecting the record for that
ID_Clients
that has the maximum value in the field EndDate.
So, sample source data
ID_Clients......EndDate
AAA.............2005-04-30
BBB............. 2005-06-30
AAA.............2006-04-30
BBB............. 2004-06-30
CCC.............2006-09-30
Desired end result:
ID_Clients......EndDate
AAA.............2005-06-30
BBB.............2006-04-30
CCC.............2006-09-30
Any ideas how I should achieve this would be appreciated.
Thanks
Ken Sheridan said:
As well as the subquery David gave you, you were actually very close to
a
solution with your second attempt. You just needed to get the MAX
value
in
a subquery:
SELECT End AS NotLatestEnd
FROM Q_Tasks_Accs
WHERE End <
(SELECT MAX(End)
FROM Q_Tasks_Accs);
Ken Sheridan
Stafford, England
:
UFF! I rethought it and can see that it would not work.
So I rewrote the query as:
SELECT Q_Tasks_Accs.End AS NotLatestEnd
FROM Q_Tasks_Accs
WHERE (((Q_Tasks_Accs.End)<(Max([Q_Tasks_Accs].[End]))));
believing it to have corrected the problem, only to get another error
message:
"Cannot have an aggregate function in WHERE
clause(Q_Tasks_Accs.End)<(Max([Q_Tasks_Accs].[End]))"
What to try next?
Hi all
My query does not work:
SELECT [Q_Tasks_Accs].[End]<(Max([Q_Tasks_Accs].[End])) AS
NotLatestEnd
FROM Q_Tasks_Accs;
I manage to save the query, but when I run it I get:
"You tried to execute a query that does not include
'[Q_Tasks_Accs].[End]<Max([Q_Tasks_Accs].[End])' as part of an
aggregate
function".
What's that all about?
[Q_Tasks_Accs].[End] is a field of dates. I wanted to create an
identical
query that returns all except the latest date.
Thanks