generating a single row from multiple 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
sravanthi
Participant
Posts: 83
Joined: Fri Jun 02, 2006 5:37 am

generating a single row from multiple rows

Post by sravanthi »

Hi,

For a parent multiple childs can be there,i need to concatenate all child records in one column in a row.I have used 3 stage variables.

s1=s2,s2=i/p column,s3=if s1=s2 then s1:',':s3 else i/p column

If i have 3 child records,i'm getting output as
1 row:1 ,
2nd row:1,2
3rd row :1,2,3

But i need only one row with 1,2,3 as my output

can anyone suggest some solution for me.
Thanks!
sravanthi
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Load that into a temp table, group by the key and get the last one. If you were on server, you could have achieved this by aggregator. I am not sure if the Last option is available in a parallel aggreagator.
Or, if the remove duplicate stage works like a hashed file stage, then pass it through the remove duplicate stage. This way you will retain the last record.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Not LAST but Maximum option it left out in aggregator.
Or simply SORT it based on the key and mark Allow Duplicate = False.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

O great. Then the Last option is going to work. Ive done something like that in the past and the last option works great.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Post by sud »

DSguru2B wrote:O great. Then the Last option is going to work. Ive done something like that in the past and the last option works great.
Simply using a filter(constraint) on the number of commas will serve the purpose.

:)
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
sravanthi
Participant
Posts: 83
Joined: Fri Jun 02, 2006 5:37 am

Post by sravanthi »

Hi all,

Thanks for your suggestion.I have used remove duplicate stage and used retain last column it worked fine.

thanks! :D
sravanthi
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

sud wrote:
Simply using a filter(constraint) on the number of commas will serve the purpose.

:)
Only if the number is known before hand :wink:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

sravanthi wrote:Hi all,

Thanks for your suggestion.I have used remove duplicate stage and used retain last column it worked fine.

thanks! :D
Make sure your data is sorted and partitioned on the key before using RemoveDuplicate stage.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply