General discussion
May 22, 2003 at 05:30 AM
ken_schreck

Union operatior with count(*)

by ken_schreck . Updated 23 years, 4 months ago

Hello,

I want to add up to table with orders into one table. If I have two tables, one with Customers and CD Orders and one with Customers and Video Orders. I only want to see how many Orders a customer placed, no matter if it is a CD or Video.
The tables have the following simple Structure:

tblCD
Customer
Order

tblVideo
Customer
Order

The following SQL will give me the summary, but I will have 2 rows for each customer, where I want just one total row for each customer.

Select Distinct Customer, Count(Order) from tblCD
UNION
Select Distict Customer, Count(Order) from tblVideo
Order by Customer

If somebody has an idea how to solve that, I would really appreciate it.

Regards Ken

This discussion is locked

All Comments