Subscribe to DSC Newsletter

How to data merging with not matching condtion.


I have two data sets data_A and data_B. data_A consists of costumer demographic information and data_B have costumer transactional information. costumer_ID is the common variable in both data set. now my question is how can i do data merging where costumer_ID not match in both data sets.

Please anyone help....

Views: 199

Comment

You need to be a member of AnalyticBridge to add comments!

Join AnalyticBridge

Comment by Michael Bain on September 22, 2010 at 5:00pm
IF this in a Ansi compliant SQL database with your data you can do a UNION to find the nonmatched "customer_IDs" (or a FULL OUTER JOIN in Oracle will also work).

If you want to insert into new table and don't need to understand from which table the original data was from ==> it's probably easiest to do two simple insert statements with LEFT Joins on unmatched data as follows.

I suggest you ask your DBA to generate queries. Here's an example.


INSERT INTO Table3 (unmatched_costumer_ID)
SELECT A.costumer_ID
FROM
data_A AS A
LEFT JOIN data_B AS B
ON A.costumer_ID = B.costumer_ID
WHERE B.costumer_ID IS NULL;

INSERT INTO Table3 (unmatched_costumer_ID)
SELECT A.costumer_ID
FROM
data_B AS A
LEFT JOIN data_A AS B
ON A.costumer_ID = B.costumer_ID
WHERE B.costumer_ID IS NULL;
Comment by Prashant on September 21, 2010 at 9:13am
Tom,

Thanks for your input,

Actually i want to create new table which represent both tables(data_A and data_B) information where data_A.costumer_ID~=data_B.costumer_ID in single step.

On Data Science Central

© 2019   AnalyticBridge.com is a subsidiary and dedicated channel of Data Science Central LLC   Powered by

Badges  |  Report an Issue  |  Privacy Policy  |  Terms of Service