Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting number of records based on Count of records 1

Status
Not open for further replies.

adam7

Technical User
Nov 26, 2002
20
GB
Hi there, I'm sure this is really simple but for the life of me I can't figure it out. I have a report whist basically just lists records in a table (8.5 SQL2000). I want to be able to say "only show the last 300 records, based on a date field". Obviously when this is run ever few minutes it still only looks at the last 300 records, regardless of the date range involved.

I've tried using counts etc... It doesn't give you a topn option as the groups I'm using are date/time fields. Any ideas at all?
 
If your database is sorted - descending by your date time field you could try this.

Create the following formula:
{@counter}<-formula name
WhileReadingRecords;
numbervar cnt:=cnt+1

Then in your selection formula use:
{@counter} <= 300

Mike
 
Hi there, thanks for the response. This does seem to have limited the records but it's actually filtering out records from the start of the database, so I think it's the first 300 records where the date field exists, which would make sence. However, I need it to look at the last 300 records entered into the database.

The only group is a date time field now.
 
Hi there, thanks for your help, with a little meddling I've sussed it out.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top