>>SUM WHILE is much better than a SUM FOR whether you have a compound expression or not. IOW if you have
>>
SET ORDER TO Cust_ID
>>SEEK m.lcCustID
>>SUM WHILE
>>
>>that will easily beat
>>
>>
SET ORDER TO 0
>>SUM FOR Cust_ID = m.lcCustID
>>
>>Especially as the number of records increases.
>>
>I created a table with 8 million records and 4 fields (I1, I2, D1, C1). I1 was populated with INT(recno()/10000). C1 was populated with PADL(1+mod(recno()),4,"0")
>
>cc = "0008"
>
>SET ORDER TO 0
>n1 = SECONDS()
>SUM I1 TO abc FOR c1 = m.cc
>? SECONDS() - n1
>
>SET ORDER TO 1
>n1 = SECONDS()
>SEEK m.cc
>SUM I1 TO abc WHILE c1 = m.cc
>? SECONDS() - n1
>
>
>The results were equivalent, with the first one seeming to be marginally faster. Strangely enough, I appeared to get best results using SUM FOR when ORDER was set to 1.
>
>This was in VFP 6.
>I'ld be interested in a similar comparison in VFP 9.
try
SET ORDER TO 1
n1 = SECONDS()
SET KEY TO m.cc
SUM I1 TO abc
SET KEY TO
? SECONDS() - n1