View Full Version : Display a range or subset of a recordset


markl
09-21-2002, 02:11 PM
Hi,

Please be kind, this is my first real post and I have it on firm authority that this IS the place to get the answers for Access.

I develop generally for the web but have had it drummed into me to create all my queries within Access or SQL Server not on the ASP page.
Sooo, I have a recordset that lifts out the top 5 results of an events db and displays them (and the associated info). What I would like to do is to perform 2 recordset sweeps from the same source but on the second one lift records 6 - 10. The db query will do all I want it to do right now, ie filter by date, event type, but I have no idea how to lift these specific files. I have explored the Top 5 * SQL option but don't really understand how to develop that further.

The reason for wanting to do this is to create a smaller listing of more distant events with smaller descriptions (yes, there is a real reason for wanting this).

Any help or suggestions would be welcome.

TIA

Mark

:confused:

Jon K
09-21-2002, 06:26 PM
The following query can rank the records in a table (or a query) based on ascending date and return the 6th to 10th records. It assumes there are no duplicate dates in the table (or query).

SELECT *
FROM TableOrQueryName as a
WHERE (select count(*) from TableOrQueryName where DateField <= a.DateField) between 6 and 10
ORDER BY DateField


To rank the records in descending date, just change <= to >=

Hope it helps.

markl
09-25-2002, 01:54 AM
Jon,

Thanks ever so much, that worked perfectly.

I knew I had come to right place!

Mark

:D