J
John Vinson
I'm trying to select the oldest transactions in a table using a select
query.
(eventually I'll convert it to an update query, but one step at a time)
I'm trying to return only one record at a time. (or the oldest records if
multiple records exist for the same date.)
(I'm providing other criteria, but still retrieving multiple records, my
goal is to apply payments to the oldest outstanding transactions)
You can do this three different ways:
- a Subquery, using a criterion of
=(SELECT Min([transactiondate]) FROM yourtable AS X WHERE <criteria>)
using criteria such as WHERE X.AccountNo = yourtable.AccountNo to find
the earliest transaction for that account; or using no WHERE clause at
all if you want to find the earliest transaction in the entire table.
- More efficiently, create a Totals query selecting the Min() of the
transaction and joining it to your table.
UNFORTUNATELY, neither of these queries will be updateable!
- Use the DMin() function to create a criterion selecting the minimum
date.