Join based on variable no of key columns

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
vamsi_4a6
Participant
Posts: 95
Joined: Wed Jun 04, 2014 12:06 am

Join based on variable no of key columns

Post by vamsi_4a6 »

I have table1(master table) consists of four columns(col1,col2,col3,col4).Another table table 2 is present.I have to join these two tables
based on col1,col2,col3 for few records and col1,col2,col3,col4 for few records,col1,col2 for few records.
currently i am using 3 join stages.Is there any way can i
use one join stage instead of three?because my key columns are not constant and it may be 1,2,3,4 columns.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What are your join rules, how do you determine which 'few records' get which combination of keys?
Last edited by chulett on Mon Sep 07, 2015 1:43 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vamsi_4a6
Participant
Posts: 95
Joined: Wed Jun 04, 2014 12:06 am

Post by vamsi_4a6 »

1)one set of records
col1='A',col2='B' and col3='C'

for the above set i need to join based on 3 three columns

2)another set of records
col1='D',col2='E'
for the above set i need to join based on 2 columns

3)another set of records

col1='e',col2='f' and col3='g' and col4='h'

for the above set i need to join based on 4 columns
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Basically create a separate join for each circumstance and develop logic to determine which result to use.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vamsi_4a6
Participant
Posts: 95
Joined: Wed Jun 04, 2014 12:06 am

Post by vamsi_4a6 »

i do not want to use 4 joins.Just want to know can rewrite the logic some other way
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

C'est impossible (pardon my French).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Create a new column where input columns are concatenated based on your joining criteria. (ABC, DE, EFGH). Use that column as key in your JOIN.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Do it in the source SQL... unless, of course, they don't all live together.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply