Merging 2 files with specail handling if there is a match
Posted: Thu May 12, 2005 11:05 am
Using DataStage PX, I am trying to figure out how to do the following:
I have 2 files that I need to merge together such that all records from File 1 and File 2 are written out UNLESS there is a match between the 2 files (key: Billing#, Ship#, Item#). If there is a match, only the 2nd File's version of the record is written.
File 1 (Customer Billing Level Prices):
Billing # - Ship# - Item# - Price
100020 - 001 - 222548 - 0.85
111111 - 001 - 160011 - 1.10
111111 - 002 - 160011 - 1.10
111111 - 003 - 160011 - 1.10
File 2 (Customer Shiping Level Prices):
Billing # - Ship# - Item# - Price
111111 - 002 - 160011 - 2.50
657454 - 001 - 555555 - 1.25
If there is a Customer Shipping Level Price that exists, it need to be used in place of the corresponding Customer Billing Level price.
Resulting Output:
Billing # - Ship# - Item# - Price
100020 - 001 - 222548 - 0.85
111111 - 001 - 160011 - 1.10
111111 - 002 - 160011 - 2.50
111111 - 003 - 160011 - 1.10
657454 - 001 - 555555 - 1.25
Does anyone have any suggestions on how this can be done? Any help would be appreciated!! Thanks.
Sara Henderson
Information Systems Department
Univar USA Inc.
I have 2 files that I need to merge together such that all records from File 1 and File 2 are written out UNLESS there is a match between the 2 files (key: Billing#, Ship#, Item#). If there is a match, only the 2nd File's version of the record is written.
File 1 (Customer Billing Level Prices):
Billing # - Ship# - Item# - Price
100020 - 001 - 222548 - 0.85
111111 - 001 - 160011 - 1.10
111111 - 002 - 160011 - 1.10
111111 - 003 - 160011 - 1.10
File 2 (Customer Shiping Level Prices):
Billing # - Ship# - Item# - Price
111111 - 002 - 160011 - 2.50
657454 - 001 - 555555 - 1.25
If there is a Customer Shipping Level Price that exists, it need to be used in place of the corresponding Customer Billing Level price.
Resulting Output:
Billing # - Ship# - Item# - Price
100020 - 001 - 222548 - 0.85
111111 - 001 - 160011 - 1.10
111111 - 002 - 160011 - 2.50
111111 - 003 - 160011 - 1.10
657454 - 001 - 555555 - 1.25
Does anyone have any suggestions on how this can be done? Any help would be appreciated!! Thanks.
Sara Henderson
Information Systems Department
Univar USA Inc.