Page 1 of 1

Concatenate Rows in Single Column

Posted: Tue Mar 15, 2011 6:26 am
by mohdtausifsh
HI
I have Requirement like this

Input
PID JOBNAME
1 A
1 B
1 C
.
.
. X


My output should be

PID JOBNAME
1 A,B,C.,.,.X

Could you please help me in acheiving in datastage

Thanks in Advance
Mohammed Tausif

Posted: Tue Mar 15, 2011 7:06 am
by chulett
That would be a 'vertical pivot' (aka rows to columns) and an exact search here will reveal the options you have.

Posted: Tue Mar 15, 2011 7:17 am
by mohdtausifsh
If it is verticle pivot for rows in to column we can acheive it in transformer,but here the rows should be concatenated in to single column.

Posted: Tue Mar 15, 2011 7:25 am
by chulett
Still a vertical pivot and to me the easiest way to solve the 'concatenation' part in a Server job is to use a Hashed File. Read and write to it in the same transformer, create a new record for each key on a lookup miss and append values on a lookup hit. Make sure you do not cache the lookup.

A search here would have revealed this.

Posted: Tue Mar 15, 2011 4:05 pm
by ray.wurlod
Or just do the appending in a Transformer stage. Follow the Transformer stage with an Aggregator stage that captures the last row of each group.

Posted: Tue Mar 15, 2011 6:34 pm
by chulett
Or that... another technique the search would have turned up. :wink:

One approach requires sorted data, the other does not.