Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random Record Selection Problems.
Message
De
15/12/2003 17:17:44
 
 
À
15/12/2003 16:58:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00859259
Message ID:
00859336
Vues:
18
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform