Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random Record Selection Problems.
Message
From
15/12/2003 17:17:44
 
 
To
15/12/2003 16:58:49
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00859259
Message ID:
00859336
Views:
19
>First, the multiplication and the rounding via INT() are redundant - they reduce the quality of the result without any apparent benefit. Second, there is no guarantee that all values assigned to the field RandSel are unique, and so there could be more than 20% selected if records with the same RandSel straddle the 20% boundary. One easy fix is augmenting the ORDER statement with the undocument 0 (for the implicit RECNO() 'column').
>
>So, the augmented Trey Walpole trick should read as follows:
>
>select top 20 percent *, 1.00000000000000 * rand() as RandSel ;
>   from finallist ;
>   order by RandSel, 0 ;
>   into table RandomList
>
>
>P.S.: I just noticed that an unqualified RAND() has a dependency on SET DECIMALS, so some multiplication is indeed necessary. I have augmented the example accordingly. Sorry.

np - works much better.
Insanity: Doing the same thing over and over and expecting different results.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform