To get the output for counting the occurence of the rows

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
ds_infy
Premium Member
Premium Member
Posts: 59
Joined: Tue Jun 09, 2009 4:17 am
Location: India

To get the output for counting the occurence of the rows

Post by ds_infy »

Hi all,
I want to get the following as output from the input provided.

input:-
a
a
a
b
b
c
d
d
d

output :-

a 1 1
a 1 2
a 1 3
b 2 1
b 2 2
c 3 1
d 4 1
d 4 2
d 4 3

Kindly suggest
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Suggest you do more than simply post input and output samples. How about spelling out your requirement in words? Telling us what you've tried and what issues you faced? :?

I see a simple dual count exercise that stage variables can solve.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ds_infy
Premium Member
Premium Member
Posts: 59
Joined: Tue Jun 09, 2009 4:17 am
Location: India

Post by ds_infy »

Can u please elaborate how we can use stage variable for getting this kind of output, im a beginner in datastage. Thanks in advance
prasson_ibm
Premium Member
Premium Member
Posts: 536
Joined: Thu Oct 11, 2007 1:48 am
Location: Bangalore

Post by prasson_ibm »

Hi,

Create stage variables in transformer in below order:-

Code: Select all

CURR=Input.Col
COUNTER=if CURR=PREV THEN COUNTER+1 ELSE 1
SEQUENCE=if CURR=PREV THEN SEQUENCE+1 ELSE SEQUENCE
PREV=CURR
Initialze SEQUENCE to 1.
Map it to output derivation.It should be your result that you are looking for.
Post Reply