Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Counting no of occurences of records in table
Message
From
09/11/2004 05:52:49
Erick Miranda
Formata Data Business - Grupo Linx
Contagem, Brazil
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 7
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00959456
Message ID:
00959469
Views:
6
Hi Neil!

>I have a table named planning in which I query a set of records into a cursor. Each record has whats known as a mainkey. There can be more than one record with the same mainkey. I would like to count the number of mainkeys in the table. For example, here is my query:L
>SELECT planning.mainkey, planning.planextra1, planning.ok, planning.okdate ;
>FROM planning ;
>WHERE planning.ok<>.t. ;
>INTO CURSOR crsresult
>A typical list of record would be:
>
>MAINKEY TYPE DATE
>JT001 Trouser 19/11/04
>JT002 Skirt 20/11/04
>JT001 Trouser 21/11/04
>
>Therefore I would like to count the number of different mainkeys. In this example the result would be 2. As there is only JT001 & JT002.
>Any help would be greatly appreciated.

Try this:
SELECT Distinct planning.mainkey ;
   FROM planning ;
   WHERE planning.ok<>.t. ;
   INTO CURSOR crsresult
lnCountMainKeys = RecCount("crsresult")
* Or
lnCountMainKeys = _Tally
I hope this helps you! 8-D
Erick
Força Sempre!
Strength Always!
Previous
Reply
Map
View

Click here to load this message in the networking platform