last

  • Thread starter Thread starter Wim
  • Start date Start date
W

Wim

Hi all,

I have to find values in a table/query where only the last
InputDate is "OK", all the other ones being valid no more.

How do I get these ?

e.g. query :

Id
Name
Price
InputDate

For the same Id I can have a price input on jan 01, 2001;
feb 01, 2002; and jan 01, 2003. I only want to pick the
price that is valid now.

Thanks,

Wim
 
Try using either the "Last" or "Max" function in the query
grid. The totals view must be selected for these options
to be available.
 
Hi Wim

You need to use a subquery in the WHERE clause. Something like this:

Select T.Id, T.[Name], T.Price, T.InputDate
from MyTable as T
where InputDate=(Select Max(InputDate) from
MyTable as X where X.Id=T.Id)
 
Graham,

Thank you, I'll give it a try.

Wim
-----Original Message-----
Hi Wim

You need to use a subquery in the WHERE clause. Something like this:

Select T.Id, T.[Name], T.Price, T.InputDate
from MyTable as T
where InputDate=(Select Max(InputDate) from
MyTable as X where X.Id=T.Id)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Hi all,

I have to find values in a table/query where only the last
InputDate is "OK", all the other ones being valid no more.

How do I get these ?

e.g. query :

Id
Name
Price
InputDate

For the same Id I can have a price input on jan 01, 2001;
feb 01, 2002; and jan 01, 2003. I only want to pick the
price that is valid now.

Thanks,

Wim


.
 
Back
Top