combining multiple rows into 1 row

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
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

combining multiple rows into 1 row

Post by sri75 »

Hi,
Can you please advice me how to achieve below logic

my source data is like this

Code: Select all

key1  key2   col1    col2    col3    col4     col5   col6   col7    col8   col9

1111   2222    **     abc     10.25
1111   2222                            $$    def     11.9     
1111   2222                                                  ##     ghi     10.4
output should be like this

Code: Select all

key1  key2   col1    col2    col3    col4     col5   col6   col7    col8   col9

1111   2222    **     abc     10.25  $$       def     11.9  ##      ghi     10.4
can we do this usiing aggregate stage instead of stage variables.

Thanks
Sri
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

sorry, my data is not looking correct

** abc 10.25 - this is first record for col1, col2 and all cother columns have spaces
$$ def 11.9 - this is second record for col 4, col5 and col6 and all other columns have spaces
## ghi 10.4 - this is third record for col7,col8 and col9

Thanks
Sri
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:!: Corrected.

Code: Select all

 tags preserve whitespace.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: combining multiple rows into 1 row

Post by chulett »

sri75 wrote:can we do this usiing aggregate stage instead of stage variables.
Yes, take the max of each column.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

Thanks chulett. I tried with max, but it is giving all zeros. do I need to take other things into consideration

thanks
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

all fileds are defined as char. I need to conver from char and integer and get the max

Thanks
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

Since you are on 8x, you can try to use "Preserve type" to prevent the conversion from char to dfloat/decimal.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Did you get this working? I'm curious why you thought you needed to convert anything, this should have worked fine with strings...
-craig

"You can never have too many knives" -- Logan Nine Fingers
greggknight
Premium Member
Premium Member
Posts: 120
Joined: Thu Oct 28, 2004 4:24 pm

Post by greggknight »

If you're on 8.5 use the looping functionality.
or use the combine records stage under the restructure tab in the palette
"Don't let the bull between you and the fence"

Thanks
Gregg J Knight

"Never Never Never Quit"
Winston Churchill
Post Reply