Help to perfom Vertical Pivot

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
snassimr
Premium Member
Premium Member
Posts: 281
Joined: Tue May 17, 2005 5:27 am

Help to perfom Vertical Pivot

Post by snassimr »

Hi !

I need to perform folowing task

Table 1 :

id Col1 Col2 Col 3
1 2 NULL NULL
1 NULL 3 NULL
1 NULL NULL 4

I need to group by according ID and to create one row in target table :

id Col1 Col2 Col 3
1 2 3 4

I there any STAGE to do it fast ? It seems the task is something opposite of task pefomed by stage PIVOT
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There's no stage for performing a vertical pivot (which is what you are asking for). Search the forum for "vertical pivot"; you should get at least two techniques, each involving an intermediate passive stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi snassimr,
I guess it is quiet stringt forward, use a transformer to make all NULL to 0, and a aggregator to group by "id" and find the max of the col1 col2 col3.


regards
kumar
elavenil
Premium Member
Premium Member
Posts: 467
Joined: Thu Jan 31, 2002 10:20 pm
Location: Singapore

Post by elavenil »

As Kumar suggessted, you can achieve this using Aggregator stage. You can use Max or Sum function to get everything in single row.

Regards
Saravanan
snassimr
Premium Member
Premium Member
Posts: 281
Joined: Tue May 17, 2005 5:27 am

Post by snassimr »

In your solution your assume that the Cols type is integer .
It seem from my example. And if it strings if there any way to do it ?
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

HI,
Not necessarly, even integer can be made to show up NULL.
simple way to convert to integer, if it is string and then proceed.

regards
kumar
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Did you try using stage variables?
Post Reply