Microsoft KB Archive/133023

= How to list number of records in each group of a SQL-SELECT Group By Clause in Visual FoxPro =

Article ID: 133023

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q133023



SUMMARY
This article shows by example how to find out how many records occur in each group of a query that groups the records in Microsoft Visual FoxPro. You can do this by using the Query Designer or the SELECT-SQL statement it creates.



Step-by-step example
This example uses the CUSTOMER.DBF table found in the VFP\SAMPLES\DATA subdirectory. The example groups the table by Country, and produces a cursor that has a record for each country with the number of records that appear in that country.

 On the File menu, click New, and then click Query. Base the query on VFP\SAMPLES\DATA\CUSTOMER.DBF. Select the Fields tab on the Query Designer. Drag the Customer.country field onto the Selected Output box. In the Functions/Expressions combo box, select the COUNT function, to count the Customer.country field. Click the Add > button to move this expression into the Selected Output box. Select the Group By tab, and drag the Customer.country field onto the Group By Fields box.  Click the SQL button on the Query Designer toolbar to see the SELECT-SQL statement that was just created. It should look like this: SELECT customer.country, COUNT(customer.country); FROM testdata!customer; GROUP BY customer.country  Close the SQL statement window. Click the exclamation button on the standard toolbar to run the query.

(c) Microsoft Corporation 2000, All Rights Reserved. Contributions by Kevin Zollman, Microsoft Corporation.

Additional query words: VFoxWin Structured Query Language akz

Keywords: KB133023

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.