Randomally select 6 Venders from a table

G

Guest

I am working on a vender database. After selecting a group of venders from a table, I need to select 6 venders from that list RANDOMALLY to produce a report. Thanks in advance
 
M

MJB1975

I would number the vendors from 1 to N in a new field in
your vendor table. Then generate 6 random number between
1 and N, and use that number to select the vendors.

-----Original Message-----
I am working on a vender database. After selecting a
group of venders from a table, I need to select 6 venders
from that list RANDOMALLY to produce a report. Thanks in
advance.
 
G

Gary Walter

Mitchel Volk said:
I am working on a vender database. After selecting a group of venders from a
table, I need to select 6 venders from that list RANDOMALLY to produce a report.
Thanks in advance.
Hi Mitchel,

The typical method is to sort your
records randomly using the Rnd function,
then choose the top 6.

Something like these examples
from Jon and Michel:

SELECT Top 6 Customers.*
FROM Customers
ORDER BY Rnd(1 + Len([CompanyName] & ""));

or if you have an AutoNumber as a Primary Key:

SELECT Top 6 Categories.*
FROM Categories
ORDER BY Rnd([CategoryID]);

Rnd() needs a non-negative, non-zero, non-null argument.

or this example from John Viescas:

SELECT Top 6 tblZips.Zipcode,
tblZips.City, tblZips.State,
FROM tblZips
ORDER BY Rnd(Asc(Left([city],1)));

Please respond back if I misunderstood
or was not clear about something.

Good luck,

Gary Walter
 

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