Page 1 of 1

giving rank codes to employees

Posted: Wed Jul 25, 2007 9:49 am
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

Posted: Wed Jul 25, 2007 1:05 pm
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.