Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL-Select Bug?
Message
From
08/12/2000 15:44:26
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00450933
Message ID:
00450963
Views:
29
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
Previous
Reply
Map
View

Click here to load this message in the networking platform