Jim Z said:
I am trying to run a query to be used in generating a survey to customers. I want
my query to return a random sample of records, (e.g., 5%) of the selected records.
In other words, I want to survey only a small, random sample of my customers.Hi Jim,
A typical method is to sort your records
randomly, then return top 5% of that sort:
- if you have a non-negative autonumber PK
(say "CustomerID" in table "Customer")
SELECT TOP 5 PERCENT Customers.*
FROM Customers
ORDER BY Rnd([CustomerID]);
- or if you have a text field
(say "CompanyName" in table "Customer")
SELECT TOP 5 PERCENT Customers.*
FROM Customers
ORDER BY Rnd(1 + Len([CompanyName] & ""));
Rnd() needs a non-negative, non-zero, non-null argument.
Please respond back if something is not clear
or I have misunderstood.
Good luck,
Gary Walter