select every nth record

K

kimdd

Is there a way to select every nth record in a query? For instance, say I am
trying to pull every 5th record of a table.
 
L

Lynn Trapp

That depends on how your database is designed. Typically there is no such
thing as a "first," "second," or "third," etc. record. However, if you
have some unbroken sequential number field you could do something like this:

Select YourIdField, SomeOtherField, AnotherField
From YourTable
Where YourIDField MOD 5 = 0;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top