Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Aggregate Problem
Message
From
06/04/2006 08:31:02
 
 
To
05/04/2006 21:56:35
John Tomblin
Service Station Systems, Inc.
San Jose, California, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7
OS:
Windows XP
Miscellaneous
Thread ID:
01110841
Message ID:
01110924
Views:
11
Hi John,

maybe it's because you are counting "Company", whereas you should be counting "Invoices"?

Try:
SELECT Company, COUNT(Invoice) as InvCount;
   FROM X1;
   GROUP BY 1
>I want to know how many invoices there are for each company.
>select company from invoices into cursor X1
>select Company, Cnt(Company)as Invoices from X1 group by 1
>select Company, count(Company)as Invoices from X1 group by 1
>
>The above all produce 1 per company even though some comapnies have 100.
>
>
>select company, 1 as Inv from invoices into cursor X1
>select Company, sum(Inv) rom X1 group by 1
>
>Also, produces 1 per company.
>
>Question 1: Why do the above not work?
>Question2: How can I get the number of invoices per company with an SQL select?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Reply
Map
View

Click here to load this message in the networking platform