Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Help Needed Please!
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00548100
Message ID:
00548182
Vues:
13
>I know I've done this before but I just can't remember how...
>
>I have two tables that I want to create one cursor from. The two tables are 1 to many. In the resulting cursor I only want to show the one values ONCE, not however many records are in the child table. (this is for reporting purposes). How can I do this in a SQL statement?
>
>Any help from the SQL gurus out there would be greatly appreciated!

As long as you have PKs and FKs, you could try [read: I have not tried this]:
select a.keyid, a.companyname, b.company_id, b.division ;
   from Company A join Division B on a.KeyID = b.Company_ID ;
   group by a.companyname into cursor crsTemp1 nofilter

select a.keyid, a.companyname, b.company_id, b.division ;
   from Company A join Division B on a.KeyID = b.Company_ID ;
   where a.keyid not in (select keyid from crsTemp1) ;
   into cursor crsTemp2 nofilter

select * from crsTemp1 ;
   union ;
select keyid, space(30) CompanyName, company_id, division ;
   from crsTemp2 order by company_id, companyname desc ;
   into cursor crsResults nofilter
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform