Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subqueries as a field expression?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00200658
Message ID:
00200672
Vues:
8
>Is there a way to use a subquery as a field expression in VFP5?
>ex:
>select CompanyName, (select sum(cost) from orders where custid = company.custid and cType = 'fruit') as TotalFruit, (select sum(cost) from orders where custid = company.custid and cType = 'beverage') as TotalBeverage from company order by CompanyName

Select custid,sum(cost) as cost from orders into cursor tmp1 where cType = 'fruit' group by custid
Select custid,sum(cost) as cost from orders into cursor tmp2 where cType = 'beverage' group by custid
Select company.custid,companyname,tmp1.cost as fruitcost From company LEFT JOIN tmp1 ON company.id=tmp1.custid Into cursor tmp3
Select companyname,fruitcost,tmp2.cost as bevtcost From tmp3 LEFT JOIN tmp2 ON tmp3.id=tmp2.custid
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform