Pivoting columns to rows

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
anudeepdasari001
Participant
Posts: 58
Joined: Mon Dec 14, 2015 3:16 pm
Location: Arizona

Pivoting columns to rows

Post by anudeepdasari001 »

Suppose i have a record say


Col1 col2
1 A,B
2 C
3 A,B,D


then i need the output as

Col1 Col2
1 A
1 B
2 C
3 A
3 B
3 D

COuld someone help me please?
anudpETL
rkashyap
Premium Member
Premium Member
Posts: 532
Joined: Fri Dec 02, 2011 12:02 pm
Location: Richmond VA

Post by rkashyap »

See this post. You can also look at thisone.
cdp
Premium Member
Premium Member
Posts: 113
Joined: Tue Dec 15, 2009 9:28 pm
Location: New Zealand

Post by cdp »

Or this
Could easily be done using the Pivot Stage.
rkashyap
Premium Member
Premium Member
Posts: 532
Joined: Fri Dec 02, 2011 12:02 pm
Location: Richmond VA

Post by rkashyap »

Usually yes, but OP's example has variable no of columns to be pivoted!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

A 'variable' number isn't a problem as long as you know the maximum possible... and that maximum isn't a really big number. :wink:
-craig

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