You tried to execute a query that does not include the specified expression <name> as part of an agg

G

Guest

I have this query

SELECT tblRefit.ID, tblRefit.Car, MAX(tblRefit.Date) AS LastDat
FROM tblRefi
GROUP BY tblRefit.Car

and I get the error "You tried to execute a query that does not include the specified expression <name> as part of an aggregate function. (Error 3122)

I can't see what is wrong with my SQL
 
M

Michel Walsh

Hi,


Using a GROUP BY clause, or an aggregate in the SELECT clause, each
expression in the SELECT clause must either be in the GROUP BY list, either
be aggregated ( SUM, MIN, MAX, FIRST, LAST, COUNT, ... ), either an
arithmetic expression involving the previous two.


If you do not use a GROUP BY clause, but use an aggregate in the SELECT
clause, there is implicitly ONE group made of the whole data ( that will
generates just one record).



Hoping it may help,
Vanderghast, Access MVP
 
V

Van T. Dinh

Try:

SELECT tblRefit.ID, tblRefit.Car, MAX(tblRefit.Date) AS LastDate
FROM tblRefit
GROUP BY tblRefit.ID, tblRefit.Car;

--
HTH
Van T. Dinh
MVP (Access)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top