Ranking system in Data stage

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
mcs@rajesh
Participant
Posts: 46
Joined: Mon Sep 24, 2007 12:37 am
Location: INDIA

Ranking system in Data stage

Post by mcs@rajesh »

Hello Friends,
I have a job similar to the ranking system in schools and colleges.. I am doing this job in Data stage and i am not getting the exact answer, for example

St_name marks
Joe 100
Tim 100
Jacob 50
Jason 20

The expected result, should be

St_name marks rank
Joe 100 1
Tim 100 1
Jacob 50 3
Jason 20 4

i tried this with all possible ways i know but i am not getting it...
sudhakar_viswa
Participant
Posts: 85
Joined: Fri Nov 18, 2005 5:35 am

Post by sudhakar_viswa »

Hi,

By using stage variables u can get this result.

Regards,
-- sudhakar
i need to know datastage
mcs@rajesh
Participant
Posts: 46
Joined: Mon Sep 24, 2007 12:37 am
Location: INDIA

Post by mcs@rajesh »

sudhakar_viswa wrote:Hi,

By using stage variables u can get this result.

Regards,
-- sudhakar
Thanks for your, reply can u walk through the steps...
stefanfrost1
Premium Member
Premium Member
Posts: 99
Joined: Mon Sep 03, 2007 7:49 am
Location: Stockholm, Sweden

Post by stefanfrost1 »

build a couple of stage varibles checking that records change and a counter and a rank. Add rank with the counter value if a record has changed, then reset the counter and continue....

pseudo code:
if this_value equals prev_value then count = count+1 else count = 1
if this_value equals prev_value then rank = rank else rank = rank+count

or something similar to that .

Remeber to have your data sorted and beware of partitioning mistakes...
-------------------------------------
http://it.toolbox.com/blogs/bi-aj
my blog on delivering business intelligence using agile principles
Post Reply