creating sequence for a group

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
dnat
Participant
Posts: 200
Joined: Thu Sep 06, 2007 2:06 am

creating sequence for a group

Post by dnat »

Hi,

I have a requirement to create sequence numbers for each group

I have the following columns in the input

Col1-Col2-Col3-Col4

1111-2222-3333-444
1111-2222-3333-444
1111-2222-3333-444
1111-2222-3333-555
1111-2222-3333-555

So,

I have two groups now

One is
1111-2222-3333-444
The next is
1111-2222-3333-555

I want the output as

Col1-Col2-Col3-Col4-Seq

1111-2222-3333-444-1
1111-2222-3333-444-2
1111-2222-3333-444-3
1111-2222-3333-555-1
1111-2222-3333-555-2

How can i achieve this.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Partition and sort your data with a Sort stage, generating a key change column. In a Transformer stage initialize a stage variable and use it
  • to reset the count to 1 if the key change column is 1

    to increment the count if the key change column is 0
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