Re: Find last record in date field for each device in the device f
- From: KARL DEWEY <KARLDEWEY@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 6 Oct 2008 08:53:00 -0700
Last may not return what you want.
The function returns the value of a specified field in the first or last
record, respectively, of the result set returned by a query. If the query
does not include an ORDER BY clause, the values returned by these functions
will be arbitrary because records are usually returned in no particular order.
Use Max function.
--
KARL DEWEY
Build a little - Test a little
"eselk2003@xxxxxxxxx" wrote:
On Oct 6, 8:16 am, sbradley-WTI.
<sbradley-...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I have an Access 2007 db that tracks testing dates for devices. Records are
entered each time a test is done. Each record records the date tested, and
90 days out as the next due date for the next test. Each record is
associated with a device. I want to query for the last record for each
device so I can create a report based on the query to tell me when the
devices are due for their next test without seeing all the history for each
device.
You would be more likely to get a more specific answer if you provide
your table layout and relationships... but, if you don't already know
about "totals", right-click in the query designer and select the
"totals" option. This adds a totals row, and you can set your date
column to Total = "Last" to show the most recent.
Here is an example of the "Last" usage in SQL format:
SELECT [DEVICE #], Last([TEST DATE]) AS [LastOfTEST DATE]
FROM TESTS
GROUP BY [DEVICE #];
Sounds like your query will have a join in it, but I can't show you
the exact SQL statement since I don't know your table names, field
names, or what field ties them together.
- References:
- Find last record in date field for each device in the device field
- From: sbradley-WTI
- Re: Find last record in date field for each device in the device field
- From: eselk2003
- Find last record in date field for each device in the device field
- Prev by Date: RE: Substituting Data on Reports
- Next by Date: Re: Substituting Data on Reports
- Previous by thread: Re: Find last record in date field for each device in the device field
- Next by thread: Re: Find last record in date field for each device in the device field
- Index(es):
Relevant Pages
|