Cumulative Sum Calculation

Solve with steps in datastage
employee_id, salary
--------------------------
10, 1000
20, 2000
30, 3000
40, 5000

Display as
employee_id, salary, cumulative_sum
-----------------------------------
10, 1000, 1000
20, 2000, 3000
30, 3000, 6000
40, 5000, 11000

Questions by sai3689   answers by sai3689

Showing Answers 1 - 6 of 6 Answers

dstage_user

  • Nov 12th, 2015
 

You can use following steps :-
1. Create 2 stage variables
a. stgvar1=> salary+ stgvar2
b. stgvar2=> stgvar1
Note :- Set initial value of stgvar2=0.
Assign stgvar2 to cumulative_sum column.

  Was this answer useful?  Yes

varun negi

  • Dec 8th, 2015
 

* You can have a single stage variable svSum with initial value = 0.
* And keep the derivation as svSum = svSum + Salary

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions