Comparison Query

S

sh

I have 2 tables of data that have a contract no, customer
name and value columns.

These tables may have similar records e.g. the same
contract no, customer name and value may appear in both
tables.

I need to run a query that will find out those records
which appear in both tables (which I can do), but to also
display ONLY those records where the value has changed.

e.g.
Table1
Contract No Customer Name Value
1001 Smith 50
1002 Jones 10
1003 Green 40

Table2
Contract No Customer Name Value
1001 Smith 50
1002 Jones 30

The query I wish to run should find the record for Jones.

Can anyone help?
 
D

Dale Fye

SH,

Try Select T1.ContractNo
, T1.CustomerName
, T1.Value as T1Value
, T2.Value as T2Value
FROM Table1 T1
INNER JOIN Table2 T2
ON T1.ContractNo = T2.ContractNO
AND T1.CustomerName = T2.CustomerName
WHERE T2.Value <> T1.Value

HTH
Dale
 

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

Top