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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query To Pull A Sampling Of Data 1

Status
Not open for further replies.

Swi

Programmer
Joined
Feb 4, 2002
Messages
1,978
Location
US
Could someone help me in writing a query to pull the first 10 records, the middle 10 records and the bottom 10 records from a table? Thanks in advance for any help.

Swi
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This seems to select the first ten rows

Code:
SELECT TOP 10 * FROM Test

I am unsure how to go about getting the middle and end sampling though.

Swi
 
After giving it some more thought maybe I could do the following to get the last 10 rows:

Code:
SELECT TOP 10 * FROM Test ORDER BY UniqueSeqNum

The problem is what if a unique sequential number is not available?

Swi
 
If you want the "first" and "last" then you must have a field or fields that describe an order. Records in tables have no order. They are like marbles in a bag.

Duane MS Access MVP
 
Ok, is there any way to just pull a random sampling then?

Swi
 
Sure, you can pull random records. Check the FAQs of this forum for at least one solution.

Duane MS Access MVP
 
Ok. thanks.

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top