Problem with Select MAX query

L

Leo Hamal

Hello I am a newbie in Access 97.

When I run the query :
SELECT DISTINCTROW MAX (TbTrans1.Date)
FROM TbTrans1
WHERE (((TbTrans1.Date) BETWEEN #01-jan-07# AND #31-jan-07#);
I get the correct date.

When I run the query :
SELECT DISTINCTROW MAX (TbTrans1.Date), (TbTrans1.NewBal)
FROM TbTrans1
WHERE (((TbTrans1.Date) BETWEEN #01-jan-07# AND #31-jan-07#);

I get error message : You tried to execute query that doesn't include the
specified expression 'NewBal' as part of an aggregate function.

When I take out MAX , I do get the full list of all transactions of January
correctly.

Any help would be much appreciated,
Leo.
 
A

Allen Browne

In query design, depress the Total button on the toolbar.
Access adds a Total row to the grid, and puts Group By under NewBal.

If you prefer to work with the SQL statement, add:
GROUP BY TbTrans1.NewBal
 
L

Leo Hamal

Allen,

when I add this I get the full list of all transactions of the month
correctly.
But, probably this was not clear in my initial message, I only need the
data for the last date of the month.
That is why I am experimenting with the MAX.

Thanks,
Leo.
 

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