>Hi all,
>
>I have a function where I have 2 FOR...ENDFOR loops where the counter is ALEN(myArray).
>
>As I go thru each array, I set my filter to match the active values of the arrays. Then I use the COUNT command with the FOR clause as a third filter. However this seems to take forever on the network. Would it be faster to set the whole filter within the COUNT statement?
>
>EX.
>
>This is what I have now:
>
>for i = 1 to alen(MyArray1)
>for j = 1 to alen(MyArray2)
>sele myAlias
>set filter to myField1=MyArray1[i] and myField2=MyArray2[j]
>go top
>count for myField3 = '1' to myVar1
>count for myField3 = '2' to myVar2
>.
>.
>.
>count for myField3 = 'n' to MyVarn
>endfor
>endfor
>
>Could this work better and faster:
>
>for i = 1 to alen(MyArray1)
>for j = 1 to alen(MyArray2)
>sele myAlias
>go top
>count for myField1=MyArray1[i] and myField2=MyArray2[j]
> and myField3 = '1' to myVar1
>count for myField1=MyArray1[i] and myField2=MyArray2[j]
> and myField3 = '2' to myVar2
>.
>.
>.
>count for myField1=MyArray1[i] and myField2=MyArray2[j]
> and myField3 = 'n' to MyVarn
>endfor
>endfor
>
>I appreciate any thoughts.
>
>TIA
Perry,
Sounds like a SQL counting by grouping :
select Field1, Field2, Field3, cnt(*) ;
from mytable ;
group by 1,2,3 ;
into array myarray
Cetin