Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL-Select Bug?
Message
From
08/12/2000 15:03:12
John Tomblin
Service Station Systems, Inc.
San Jose, California, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
SQL-Select Bug?
Miscellaneous
Thread ID:
00450933
Message ID:
00450933
Views:
79
In many cases, I maintain 2 identical tables, one with active records and the other for historical records. Most of the time, the app is working only with the active records, which is a much smaller table. This speeds up the applications dramatically.
The problem is that sometimes I need to get records from both of the identical tables. For example: I have active and historical invoices and I'd like to know the total number of invoices for each customer. If I execute the following SQL-Select, I will get one record for each customer except one, which will have two records (one from each table).
Does anyone know a single SQL-Select statement that will produce one record for each customer?

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
Next
Reply
Map
View

Click here to load this message in the networking platform