Probably A Stupid Query Question

G

Guest

I have two large data tables. The field I want to compare is a text type
field that contains cost center information. One large table contains the
entire set of cost centers and related information that I want to analyze.
Another table contains a subset of the cost centers. How do I query to get
the "difference?" I know how to easily find the join of the tables (the
subset of the information in the larger table that includes only all the
records from the large file that are also in the smaller subset table). But I
can't figure how to get the data in the large table corresponding to the cost
centers that are NOT in the smaller subset of cost centers table. I hope this
is clear. Can anyone help me write the query?
 
B

Bongard

Create a new query in design view. Add the two tables for which you
wish to compare. When you see the two tables in the design view of the
query click on one of your 2 join fields and drag to the corresponding
join field in the other table (a line should appear) then double click
on fields to add them to the query. For your comparison field Your
going to have to explain how you want to compare the two fields. What
type of field is in table B, and what kind of comparison do you want
to do? You could start with something simple like entering
"ComparisonField:Iif(tableA.field1=tableB.field2,"True","Doesn't
match") in the field row of one element of your query.

Let me know how you want to compare and I can suggest something more
 
J

Jamie Collins

One large table contains the
entire set of cost centers and related information that I want to analyze.
Another table contains a subset of the cost centers.
I
can't figure how to get the data in the large table corresponding to the cost
centers that are NOT in the smaller subset of cost centers table.

Using Northwind: customers who have made no orders:

SELECT C1.CustomerID, C1.CompanyName
FROM Customers AS C1
WHERE NOT EXISTS (
SELECT *
FROM Orders AS O1
WHERE O1.CustomerID = C1.CustomerID);

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top