Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Correct
Message
From
08/10/2011 07:34:09
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
08/10/2011 02:01:13
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01525797
Message ID:
01525890
Views:
69
You can easily combine records with a GROUP BY, as follows:
select F1, F2, count(*) as HowMany;
  from MyTable;
  group by F1, F2;
  order by F1, F2;
  into cursor Temp
That will give you the count for each combination in a separate record. If you want all the data for the same value of F1 in the same record, you can then write a loop to transfer that into the final result.

>thank you for reply, sorry for that ,
>i need to count f2 , and count the duplicated records(f2)
>f1 f2
>1 a
>1 a
>1 b
>1 b
>1 b
>1 c
>1 c
>1 d
>1 d
>1 d
>1 d
>2
>2
>2
>2
>
>.
>.
>.
>**********************result
>f1 f2 f3
>1 11 4
>
>
>>Once more, "code does not work" is not a clear description of the problem. If you get an error message, you should say what is the error message. If the code doesn't do what you expect it to do, you should explain what you expect it to do, and how it fails (i.e., what does the code do that is different from your expectations).
>>
>>>hi all,
>>>
>>>i need help to correct this code,
>>>i try to use this code not work
>>>
>>>
>>>CLOSE ALL
>>> Local lnOffice
>>>
>>>USE salah2
>>>SELECT DISTINCT no from salah2 INTO CURSOR junk
>>>
>>>SCAN
>>> lnoffice = junk.no
>>>.
>>>.
>>>
>>>endscan
>>>
>>>
>>>
>>>
>>>i need to correct this code with another way
>>>
>>>CLOSE ALL
>>>USE salah2
>>>SET FILTER TO no=20&&lnoffice = junk.no
>>>COUNT TO s
>>>*brow
>>>SELECT DISTINCT no,dept  FROM salah2 WHERE no=20  INTO CURSOR mycur
>>>*brow
>>>m.dept=dept
>>>m.no=no
>>>*? dept,no
>>>COUNT TO k
>>>*? k, s,dept,no
>>>
>>> USE mytable
>>> APPEND BLANK
>>> replace no WITH m.no
>>> replace nam WITH m.dept
>>> 
>>> replace dis WITH k
>>> replace all WITH s
>>> *****************************************************************
>>>CLOSE ALL
>>>USE salah2
>>>SET FILTER TO no=42
>>>COUNT TO s
>>>brow
>>>SELECT DISTINCT no,dept  FROM salah2 WHERE no=42  INTO CURSOR mycur
>>>brow
>>>m.dept=dept
>>>m.no=no
>>>*? dept,no
>>>COUNT TO k
>>>*? k, s,dept,no
>>> USE mytable
>>> APPEND BLANK
>>> replace no WITH m.no
>>> replace nam WITH m.dept
>>> 
>>> replace dis WITH k
>>> replace all WITH s
>>>***********************
>>>CLOSE ALL
>>>USE salah2
>>>SET FILTER TO no=...etc
>>>.
>>>.
>>>.
>>>
>>>
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform