query return a randomly selected subset of records

B

BayDeltaDev

Hello,

I want to retrieve 10% of the records in a table, but want them to also be
randomly selected. In other words, I want to randomly subsample a group of
records.

Does anybody know how this can be done, either in SQL or VBA?

Thank you very much.
 
D

Duane Hookom

This question would have been more appropriate in the MS Access Queries NG.
You can select the TOP 10 PERCENT of the records ordered by the RND()
function like:

SELECT TOP 10 PERCENT Rnd([OrderID]) AS Expr1, Orders.*
FROM Orders
ORDER BY Rnd([OrderID]);
 

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