Aggregating data

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

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

Aggregating data

Post by sri75 »

HI,

I have source data like this

Code: Select all

Ubox empno week  fri      sat      sun    mon      tue      wed      thu
 
134   111       1      2        3      3       0         0       0         0
134   111       2      1        2      1       1         2       3         4  
134   222       1      1        2      5       1         4        5        6
134   222       2      4        3      4       5         6        7        8    
I want the out pu tlike this

Code: Select all

Ubox empno week  fri    sat      sun    mon      tue      wed      thu  total  gt
 
134   111       1      2        3      3       0         0       0         0         8
134   111       2      1        2      1       1         2       3         4        14      22
134   222       1      1        2      5       1         4        5        6        24
134   222       2      4        3      4       5         6        7        8         37     51

for each employee hours of week1 (8 hrs) and also hours of week 2 (14 hrs) and total hours 22 and also hours of all employees of week1and week2 on each day



Can you please tell me how to do this with aggregator stage or any other logic

Thanks
Sri
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You'll want to order your data, as you need running totals. Stage variables seem to be the best way to do things.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

HI Kenneth,

Thanks for your reply. I don't need running total, i need total hours of week1 and week2 for particulat employee and total hours of all employees in week1 as well as week2


Thanks
Sri
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Stage variables are still a good way to collect running totals from sorted data. When it's the second week number, append a line terminator and the total to the final column and write to a sequential file, then read from that sequential file to get the desired result. Put the grand total in the user status area and use an after-stage subroutine to append that to the file.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

Thanks Ray for your suggestions.I will try it
Post Reply