giving rank codes to employees

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

giving rank codes to employees

Post by sri75 »

hi
my data is like this

emplid name groupid

11111 Y UHH
22222 Z UHH
12345 x UHH
12345 X UHF
12345 X UHG
12345 X UHM
33333 M UHG

Data is in sequential file.I used sort stage to sort the data
Requirement is, we need to give the rank to group id if one employer belongs to more than one group.If there is only one employer just default to 0

In the transformer stage, I used this logic

svPreviousRec = svCurrentRec
svCurrentRec = input.emplid
svChangeRecord = If svCurrentRec <> svPreviousRec Then 0 Else svRecordCount+1
svRecordCount = If svChangeRecord=0 then 0 else svRecordCount + 1

initial value of svRecordCount is 0

I got the result set like this

emplid name groupid rank

11111 Y UHH 0
22222 Z UHH 0
12345 x UHH 0
12345 X UHF 1
12345 X UHG 2
12345 X UHM 3
33333 M UHG 0

But I need to get this way.

emplid name groupid rank

11111 Y UHH 0
22222 Z UHH 0
12345 X UHH 1
12345 X UHF 0
12345 X UHG 3 (this is highest rank group)
12345 X UHM 2
33333 M UHG 0

Can you please help me out

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

Post by ray.wurlod »

Can't you just sort the result again, by emplid then by rank in descending order? Or run it through an Aggregator stage grouping by emplid, name and groupid and returning max(rank).

Incidentally, choose a different term. What you have is not a rank, it's merely a counter.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply