Help with date criteria.

  • Thread starter Thread starter Freddie
  • Start date Start date
F

Freddie

Can anyone advise of how to accomplish the following issue. I have a table
with that I import data in on a given date. I then run a report analyzing
data but only analyzing the maximum two rows of data based on dates
comparison, always the maximum and the prior date before it. Let's say I
have a record as such
Example:

Row 1: 1/15/2003
Row 2: 1/30/2003

I then import new records, now my table looks like this

Row 1: 1/15/2003
Row 2: 1/30/2003
Row 3: 2/15/2003

At this point I would like to see data for only row 2 and 3 using the max
date and the prior date before it.
I then import yet another row of data. My table now:

Row 1: 1/15/2003
Row 2: 1/30/2003
Row 3: 2/15/2003
Row 4: 2/28/2003

I would then report on rows 3 and 4. As I import a new row, I would then
always want to analyze the last two rows. Any advice? Not sure how to get
only the last two rows.


Thanks,

Fred
 
I would then report on rows 3 and 4. As I import a new row, I would then
always want to analyze the last two rows. Any advice? Not sure how to get
only the last two rows.

Use the TOP VALUES property of the query:

SELECT TOP 2 * FROM yourtable ORDER BY datefield;
 
Back
Top