Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A simple SQL but with the count of the child records
Message
De
20/08/2006 23:39:26
 
 
À
20/08/2006 23:05:04
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01147165
Message ID:
01147176
Vues:
22
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform