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 23:39:26
 
 
To
20/08/2006 23:05:04
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:
01147176
Views:
20
>I don't know how to do this with a subquery.
>
>If you don't mind separate queries - which is often faster, and more manageable, IMO - you might circumvent the GROUP BY problem as follows.
>
>
>select count(*) as HowMany;
>  from Child;
>  group by Master;
>  into cursor Tmp;
>  nofilter
>select ma.Field1, ma.Field2, ma.Field3, ..., nvl(ch.HowMany, 00000);
>  from Master ma left join Child ch on ma.Master = ch.Master;
>  group by ma.Master;
>  into cursor Tmp
>
>
>Note that this (untested) example would also solve the problem of zero child records.

I need to do it in one query. Naomi provided the way to achieve it.
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
Reply
Map
View

Click here to load this message in the networking platform