Page 1 of 1

To get the output for counting the occurence of the rows

Posted: Wed May 29, 2013 7:04 am
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

Posted: Wed May 29, 2013 7:21 am
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.

Posted: Wed May 29, 2013 7:30 am
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

Posted: Wed May 29, 2013 7:44 am
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.