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!

Help with randomize

Status
Not open for further replies.

HenryAnthony

Technical User
Feb 14, 2001
358
US
Hi,

I am trying to follow steps found in other threads to randomly order a query of 2009 records. I get an error: Compile error in query expression 'rnd([MyTable].NumField)' Here is my SQL:

SELECT TOP 2009 [MyTable].NumField
FROM MyTable
ORDER BY rnd([MyTable].NumField);

I got my example from faq701-2534. The faq text follows: This FAQ outlines a way of retrieving a random set of records for audit or other prurposes. The method requires that the table has a numerical field on which to operate. The sql is very simple

select top X from yourtable
order by rnd(numericalfield)

This will give the x records and will be different everytime it is run.

Regards,
Henry
 
OK, folks. Forget it. For some reason, all functions in this database returned the same compile error. I imported the tables into a new database and everything works just fine. Now I am wondering how this happens.

Regards,
Henry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top