Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL-Select Bug?
Message
De
08/12/2000 15:44:26
 
 
À
08/12/2000 15:20:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00450933
Message ID:
00450963
Vues:
30
Daniel:

>>>>
select customer, sum(invoices) from ;
(select Customer, count(InvNum) as Invoices;
from ActiveInvoices;
group by Customer;
union select Customer, count(InvNum) as Invoices;
from HistInvoices;
group by Customer;
order by Customer)
group by customer
>>>>

This does not work because the UNION clause does not work in subqueries...

I don't know of any way to do this in one pass but this works:


Select Customer, count(*) As ActInv, 0 As HisInv ;
From ActiveInvoices ;
Group By Customer ;
Union Select Customer, 0 As ActInv, Count(*) As HisInv ;
From HistInvoices ;
Group By Customer ;
Into Cursor TotInv

Select Customer, Sum(ActInv + HistInv) As InvCount ;
From TotInv ;
Group By Customer


Daniel
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform