Page 1 of 1
generating a single row from multiple rows
Posted: Mon Jun 26, 2006 7:52 am
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!
Posted: Mon Jun 26, 2006 7:56 am
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.
Posted: Mon Jun 26, 2006 9:07 am
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.
Posted: Mon Jun 26, 2006 9:45 am
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.
Posted: Mon Jun 26, 2006 3:40 pm
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.
Posted: Mon Jun 26, 2006 11:51 pm
by sravanthi
Hi all,
Thanks for your suggestion.I have used remove duplicate stage and used retain last column it worked fine.
thanks! :D
Posted: Tue Jun 27, 2006 6:57 am
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
Posted: Tue Jun 27, 2006 8:52 am
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.