Pivoting with Number of iterations

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
wittyme
Premium Member
Premium Member
Posts: 151
Joined: Tue Sep 15, 2009 2:03 pm
Location: Chicago

Pivoting with Number of iterations

Post by wittyme »

Need help with code

Source Data

code address
a1 xyz
a1 abc
b1 a23
b1 xmn
b1 dkl
c1 lmo
a2 pqs
a2 sfo
d1 dnm
d1 knm
d1 gnm

Required Output

code address
a1 xyz abc
b1 a23 xmn dkl
c1 lmo
a2 pqs sfp
d1 dnm knm gnm


The number of times the code may repeat is unknown. So need to pivot based on the no. of times code repeats.

Needs inputs on the design methods on how to achieve this.

Thank you!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

One typical solution would be to concatenate the 'address' values together via stage variable per group, writing each resulting record out and then using a Remove Duplicates stage to keep only the 'last' duplicate per group.
-craig

"You can never have too many knives" -- Logan Nine Fingers
wittyme
Premium Member
Premium Member
Posts: 151
Joined: Tue Sep 15, 2009 2:03 pm
Location: Chicago

Post by wittyme »

Thank you!

Found a similar post in DSxchange. Initially my search didn't pull any as subject is not appropriate for the other post.

If someone opens this message, here is the solution link.
Post Reply