Thursday, 8 August 2013

SQL Server Comparing how many data matches, and only in one tables

SQL Server Comparing how many data matches, and only in one tables

I have two tables: CustomerInformation
CustomerName CustomerAddress CustomerID LocationID BillDate
CITY - 1 500 N ST 47672001 29890 2012-07-20 00:00:00.000 0
CITY - 1 500 N ST 47672001 29890 2012-07-20 00:00:00.000 6890
CITY - 1 500 N ST 47672001 29890 2012-08-17 00:00:00.000 0
CITY - 9 510 N ST 47643241 29890 2012-08-17 00:00:00.000 5460
CITY - 4213 500 S ST 43422001 29890 2012-09-17 00:00:00.000 0
CITY - 5 100 N ST 23272001 29890 2012-09-17 00:00:00.000 4940
CITY - 3 010 N ST 43323001 29890 2012-10-19 00:00:00.000 0
CITY - 78 310 N ST 12222001 29890 2012-10-19 00:00:00.000 5370
and CustomerMeters has three columns: ID, Name, Address
The connection between these two tables is: CustomerAddress, so I can join
the two based on Address:
SELECT * FROM CustomerInformation
JOIN CustomerMeters
ON CustomerAddress = Address
Now, the problem is I have so many records (over 20000 in the
CustomerInformation), Is there away that I list how many records that
matches in both tables, and how many records are only in the
CustomerInformation table?
Thank you.

No comments:

Post a Comment