Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Selecting 10 records randomly
Message
From
05/01/1998 18:14:08
 
 
To
05/01/1998 11:16:22
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00069291
Message ID:
00069675
Views:
39
>>
>>
>>SELECT TOP 10 Table.field1, RAND() AS Dummy;
>> FROM Table;
>> ORDER BY 2;
>> INTO CURSOR tmpStore
>>
>
>This is the perfect solution with an exception. rand() might return the same value for top 10 more than once thus resulting set would be more than ten recs. Sure not a problem just get the first ten recs than.

Depending on your application if this is a problem you can put a second sort order in the query based on the table's primary id field. You elimnate the problem of more than extra recs and still keep the randomizing effect.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform