Return every nth record? - newbie

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello.

I am trying to get a result of returning every 4th record in a database of
thousands.

Not sure how to go about the process?
 
In order for "every 4th record" to be meaningful, you must have a primary
key that defines uniquely defines the order of records.

For this example, we will assume it is an AutoNumber named ID, and the table
is named Table1.

You could get a counter in your query by typing a subquery such as this into
a fresh column of the Field row in query design:
(SELECT Count(ID) FROM Table1 AS Dupe WHERE Dupe.ID <= Table1.ID)

To get every 4th record, use Mod 4. The expression in the Field row is
therefore:
(SELECT Count(ID) FROM Table1 AS Dupe WHERE Dupe.ID <= Table1.ID) Mod 4
In the Criteria row, enter:
0
Uncheck the Show box in query design. (Results will be read-only if you do
not clear this box.)
 
Back
Top