>>Because of the WHILE.
>>
>>Is this your way of saying that you really didn't have the SEEK in your original test?
>
>No, this is what I'm saying precisely:
>
>seek and then sum while myCond should return exactly the same result as select where myCond, but they do not do this. If I do seek and then select sum vs. SUM they match. I should not do SEEK before SELECT SUM. Thus I conclude that my indexes are corrupted. In two mismatch cases I found by these tests first time the invoice was for different salesman and the second case it was not in the table at all. I tried to SEEK invoice using SET EXACT OFF, SET ANSI OFF, SET DELETED OFF. Paradoxycally, SELECT * from table where inv = my Bad Invoice also returned 0 records. So, why do I have these weird results running code is still a mystery.
>
>I just re-indexes the table on Com_Inv (Inv_No + salesman) and I got the bad results again
>
>Found a mismatch on I801972COL cRate = 0 laArr[1]= 0.100000000
>Found a mismatch on I518767COL cRate = 0 laArr[1]= 0.100000000
Are you sure the SQL is pulling the same records? AFAIK, in VFP8 we didn't have the support for SQL reading from the buffers, so maybe your SQL statement reads from the file on disk, while your SUM command refers to current buffers?