Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
COUNT taking too long on network
Message
From
05/01/1999 00:56:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00172498
Message ID:
00172655
Views:
29
>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 && into cursor myCursor more parctical ?
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform