Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Randomly select n unique codes from 5mln table
Message
De
09/11/2001 10:03:29
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00579211
Message ID:
00579641
Vues:
26
Mark,

I wonder whether your solution might not share the same problem as some of the other solutions proposed, for a large table, namely speed. In other words, VFP will be forced to evaluate the condition for each and every record. Perhaps VFP will actually retrieve each and every record, and only then evaluate the condition.

Of course, speed may actually not be a critical concern, since usually you won't need to create sample data every day - only once.

>>Hi everybody,
>>
>>How can I randomly select n (110) codes from some huge table, so these codes would be unique? I'm trying to create a test case now...
>
>You could determine the total number of records in the table, and from that determine the percentage needed to get the number of records you want. Then try:
>
>select * from MyTable having rand() < lnPct
>
>where lnPct is something like 0.05 for 5 percent. This will not be exact because rand() may not return enough values below lnPct to get the number of records you want.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform