how to get cumulative sum
Moderators: chulett, rschirm, roy
how to get cumulative sum
source
id,sal
10,1000
20,2000
30,3000
40,5000
target:
id,sal,cum_sum
10,1000,1000
20,2000,3000
30,3000,6000
40,5000,11000
id,sal
10,1000
20,2000
30,3000
40,5000
target:
id,sal,cum_sum
10,1000,1000
20,2000,3000
30,3000,6000
40,5000,11000
jhansi
-
- Participant
- Posts: 3
- Joined: Thu Apr 26, 2012 2:11 am
- Location: Chennai
Re: how to get cumulative sum
hi,
this will get by using transformer stage.
here u can take three stage variables like sv1,sv2,and sv3.
Assign default values as 0.
sal -> sv1
sv1+sv2 -> sv2 this one drag to cum_column
sv2 -> sv3
i think this is help u.
this will get by using transformer stage.
here u can take three stage variables like sv1,sv2,and sv3.
Assign default values as 0.
sal -> sv1
sv1+sv2 -> sv2 this one drag to cum_column
sv2 -> sv3
i think this is help u.
Madhu
-
- Participant
- Posts: 3
- Joined: Thu Apr 26, 2012 2:11 am
- Location: Chennai
Re: how to get cumulative sum
hi,
this will get by using transformer stage.
here u can take three stage variables like sv1,sv2,and sv3.
Assign default values as 0.
sal -> sv1
sv1+sv2 -> sv2 this one drag to cum_column
sv2 -> sv3
i think this is help u.
this will get by using transformer stage.
here u can take three stage variables like sv1,sv2,and sv3.
Assign default values as 0.
sal -> sv1
sv1+sv2 -> sv2 this one drag to cum_column
sv2 -> sv3
i think this is help u.
Madhu
Re: how to get cumulative sum
k its working.i did one small mistake
Last edited by jhansi on Thu Jun 14, 2012 7:17 am, edited 1 time in total.
jhansi
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Re: how to get cumulative sum
No need of S3.
Also records need to be sorted by by ID![Smile :)](./images/smilies/icon_smile.gif)
Also records need to be sorted by by ID
![Smile :)](./images/smilies/icon_smile.gif)
-
- Participant
- Posts: 3
- Joined: Thu Apr 26, 2012 2:11 am
- Location: Chennai
Re: how to get cumulative sum
sorry actually i want to said this one
sal -> sv1
sv1+sv3 -> sv2 this one drag to cum_column
sv2 -> sv3
without sv3 also working previous one
sal -> sv1
sv1+sv3 -> sv2 this one drag to cum_column
sv2 -> sv3
without sv3 also working previous one
Madhu
Re: how to get cumulative sum
if st1 is null then SAL else st1+SAL--------st1
(OR)
if @inrownum=1 then SAL else st1+SAL--------st1
map st1 to sumcolum
make sure the data should be sorted based on SAL
(OR)
if @inrownum=1 then SAL else st1+SAL--------st1
map st1 to sumcolum
make sure the data should be sorted based on SAL
Re: how to get cumulative sum
both are also working good.
ntr wrote:if st1 is null then SAL else st1+SAL--------st1
(OR)
if @inrownum=1 then SAL else st1+SAL--------st1
map st1 to sumcolum
make sure the data should be sorted based on SAL
jhansi
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Is this an interview question?jhansi wrote:without transformer can we do this scenario?
Why do you want to do it without a Transformer stage?
It used to be the case that the Transformer stage was inefficient but they did a lot of work to it (version 8.1.x ?) and that advice is no longer correct.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.