Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A simple SQL but with the count of the child records
Message
From
20/08/2006 22:47:15
 
 
To
20/08/2006 22:44:11
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01147165
Message ID:
01147169
Views:
18
>I think the basic idea is something like this:
>
>
>select Master.Master, count(*) as HowMany;
>  from Master join Child on Master.Master = Child.Master;
>  group by Master;
>  into cursor Temp
>
>
>Additional adjustments may be needed if there is the possibility of master records without child records. A left join, for a start.

Yes, this works if I only have one field to use. But, using that approach when I have a lot of fields from the master table to include in the SQL will produce a SQL error on the GROUP BY.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform