generating sequantial numbers

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
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

generating sequantial numbers

Post by DSguru2B »

hi guyz,
having a bit of issue achieving the following
source:
1
1
1
2
2
3
3
3

how to get the following
1 1
1 2
1 3
2 1
2 2
3 1
3 2
3 3

is there any built in function in ds that can achieve that. i tried my best, couldnt find any.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

DSGuru2B,

you can solve this type of problem by using stage variables. The first stage variable is called SeqNo and have the derivation "IF (In.NumberColumn=LastNumberColumn) THEN SeqNo+1 ELSE 1" and the second is called LastNumberColumn and is derived with "In.NumberColumn". This depends on your source being sorted on your In.NumberColumn; but since that is what your sample shows I'll assume that this is the case.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Great....Thanks buddy!!!
Post Reply