Datastage Senario?

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
A_SUSHMA
Participant
Posts: 43
Joined: Fri Apr 12, 2013 10:34 am

Datastage Senario?

Post by A_SUSHMA »

I need the below output please let me know how to do in ds


Input
101 1000
101 2000
101 3000
201 1000
201 4000

Output
101 1000
101 3000
101 6000
201 1000
201 5000
ssnegi
Participant
Posts: 138
Joined: Thu Nov 15, 2007 4:17 am
Location: Sydney, Australia

Reply

Post by ssnegi »

In Transformer Hash Partition & Sort COL1 ascending.
Dont partition sort only COL2 Ascending. Then use stage variables.

svsum : if DSLINK.COL1 = svCOL1old then svCOL2 + DSLINK.COL2 else DSLINK.COL2
svCOL1old : DSLINK.COL1
svCOL2 : svsum

Output Col1 : DSLINK.COL1
Output Col2 : svsum
Last edited by ssnegi on Mon Mar 03, 2014 5:46 pm, edited 2 times in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or use a Sort stage to generate a Key Change column on the first field and then all you need is:

Code: Select all

svRunningTotal: If KeyChange then COL2 else svRunningTotal + COL2
And of course, mind your partitioning.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply