>That's what i want but is there a way to keep original set of records in the table.
Then index the cursor on field a, and write a loop like this:
select mytable
set order to a desc
do while !eof()
lcA=mytable.a
if seek(mytable.a, "temp")
replace a with temp.c
endif
count while mytable.a=lcA
enddo
So you don't have two loops, you have one select and one loop.
>>>I need to sum a set of fields by an other field in a table and i'd like to know if my idea is good enough.
>>>(It seemed to be a bit clumsy).
>>>The table is like this
>>>A B C
>>>aa 1 1
>>>bb 2
>>>bb 3
>>>bb 4 9
>>>cc 5 5
>>>dd 6
>>>dd 7
>>>dd 8 21
>>>
>>>So I should sum field "B" by field "A" in the filed "C". I would use 2 do while loops, one of them goes through the table and the other one would sum up the filed B if there are more than two identical ones in field "A". Does it seem ok?
>>
>>I am not sure what exactly you want, but if you want the total for each different text in field "A", a SELECT with a GROUP BY clause will do the job, for example:
>>
>>
>>select a, sum(b) as total_b;
>> from MyTable;
>> group by a;
>> into cursor Temp
>>