Pulling a Random Sample in MS Access
October 27th, 2008 Posted in tech tipsI have a database with 500,000 records and I need to pull 12000 random records for analysis. The WHERE clause is not necessary for the random sampling. It is just part of the query that was used in this case.The simplest way to do this is to randomize the sort order and use a SELECT limiter as follows.
SELECT TOP 12000 customers.first_name, customers.last_name, customers.street_address, customers.city, customers.state, customers.zip, customers.country, customers.email FROM customers WHERE (((customers.state) In ("NH","VT","ME","MA","RI","CT","NY","NJ","CA","WA","OR","DC","MD","PA","VA")) AND ((customers.email) Is Not Null)) ORDER BY Rnd(ID); |
One Response to “Pulling a Random Sample in MS Access”
By Bipping B Dorskstuffing on Sep 10, 2009
This seems like the imbecilic rantings of a lunatic who does not know Microsoft Access.