Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record comparison on two tables

Status
Not open for further replies.

leftfldr

Programmer
Mar 30, 2005
23
US
Using SQL2008 I have two pricing tables that have the exact same columns. I need to find the records in 1 table that do not exist in the other table.

If TABLE A has a Price Level and Unit of Measure combination = CATPRICE EX I need to know which of those item numbers do not have a Price Level and Unit of Measure combination = NET EX in TABLE B

EXAMPLE

TABLE A
Item Number,Price Level,Unit of Measure, UOM Price
MD855, CATPRICE, EX, 100
MD841, CATPRICE, EX, 200
MD832, CATPRICE, EX, 200

TABLE B
Item Number,Price Level,Unit of Measure, UOM Price
MD855, NET, EX, 300
MD841, NONE, EX, 200
MD832, NET, EX, 600

The query would need to return MD841.

Any help would greatly be appreciated!
 
Select *
from tablea a
left join tableb b
on A.[item number]=b.[item number]
And A.[Unit of Measure]=b.[Unit of Measure]
And A.[UOM Price]=b.[UOM Price]
Where B.[item number ] is null
 
I would not want to set the Unit of Measure and Unit of Measure Price equal to each other would I since I want to compare CATPRICE EX to NET EX?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top