Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fastest way for sum records
Message
De
08/12/2008 12:24:22
 
 
À
08/12/2008 09:14:50
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01365809
Message ID:
01366002
Vues:
11
>>>>Hi all,
>>>>I have a table with at least 200000 records in it.
>>>>IdField and Payment are its fields.
>>>>What is the fastest way to getting sum of payment for some records?
>>>>Is SUM command suitable for this?
>>>>SUM Payment ALL FOR IdField=2134 TO SumPayment
>>>
>>>select sum(Payments) as TotalPayments from myTable where IDField = 2134 into cursor c_TotalPayments
>>>
>>>?  nvl(c_TotalPayments.TotalPayments,0)
>>
>>
>>If there's an index on IdField, the following may be faster
>>
>>local SumPayment, IdToDo
>>SumPayment = 0
>>IdToDo = 2134
>>
>>&& set order to the index on IdField
>>&& best set talk Off
>>
>>if( seek(m.IdToDo, 'AliasName') )
>>    sum Payment rest while (IdField == m.IdToDo) to SumPayment
>>endif
>>
>>
>
>I can't think of any way where it would be slower.

CALCULATE SUM() is little faster,
and REST can to be removed...
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform