Rows to 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
sanjeev_sithara
Participant
Posts: 15
Joined: Wed May 26, 2004 6:30 am

Rows to columns

Post by sanjeev_sithara »

Hi,

How do you achieve the following in a parallel job:

I have a source in the following format

Id Name

----- ---------

1 xx

1 yy

1 zz

2 xx1

2 yy1

2 zz1

3 xx2

3 yy2

3 zz2


I want to get the data in the target as following


id name1 name2 name3

----- -------- ---------- ----------------

1 xx yy zz
2 xx1 yy1 zz1
3 xx2 yy2 zz2

Are there any specific stage to do this.
Any help is highly appreciated.

Thanks
djm
Participant
Posts: 68
Joined: Wed Mar 02, 2005 3:42 am
Location: N.Z.

Post by djm »

As your are on unix, if the data is going to have a consistent number of rows each time (e.g. in your example always 3 rows to be turned into 3 columns), the unix "paste" command will achieve this. Try the commnad "man paste" for an explanation.

David.
sanjeev_sithara
Participant
Posts: 15
Joined: Wed May 26, 2004 6:30 am

Post by sanjeev_sithara »

Thank You for your reply.The number of rows neednot be consistent.It just turned out to be like that in my example.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi,
Pls search for the topic "Vertical Pivot" in the forum

-Kumar
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

Read up on the Pivot Stage in your Ascential Documentation.
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That would perform a Horizontal Pivot, basically the exact opposite of what the OP needs to do.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

:oops: .

sorry(And Thanks) craig,

Note to self: Do not post just after getting up!!
Amey Vaidya<i>
I am rarely happier than when spending an entire day programming my computer to perform automatically a task that it would otherwise take me a good ten seconds to do by hand.</i>
<i>- Douglas Adams</i>
Post Reply