Vipul Reddy
Vipul Reddy

Reputation: 33

How to find sum of a column in datastage

I need the output in below mentioned form

Input

Id marks

1 20

2 10

3 40

Required Output :

Id marks sum

1 20 20

2 10 30

3 40 70

Upvotes: 0

Views: 3659

Answers (2)

Abhisek
Abhisek

Reputation: 21

By storing the previous value into stage-variables and retrieving these while adding to current value.

sv_prev_value=0 add the current record and update stage variable container to 20 for first record. proceeding further repeat the same to hold the prev value and add it to ur current number. I hope you got some ideas.

Upvotes: 1

Dan Griffiths
Dan Griffiths

Reputation: 321

The way I would complete this within Datastage is to utilise the looping function within the transformer stage. Documentation from IBM is available here; IBM Loop Example

I believe the first example should suffice, you will need to pull in a consistent column that has a single value (eg NewCol = 1 for all entries if you want to sum all values for your entries)

Then change the percentage calculation example from calculating the percentage to just passing the sum through (which is already part of the example)

You can probably complete this without the LastRowInGroup function and by amending some of the stage variables, others here will undoubtedly have a cleaner answer for you

I hope this helps give you some ideas on how to progress your issue

Upvotes: 0

Related Questions