Datastage Scenario Based Question/Answer : 4
Duplicate Occurrences Count...!
Input is like this:
Col1,Col2
1,a
2,b
3,a
4,b
5,a
6,a
7,b
8,a
Output is in this form with row numbering of Duplicate occurrences.
Output:
Col1,Col2,Col3
"1","a","1"
"6","a","2"
"5","a","3"
"8","a","4"
"3","a","5"
"2","b","1"
"7","b","2"
"4","b","3"
Solution 1 :
Source => Sort =>Transformer=>Output
1. Read the source data.
2. A) Sort the source data on Col2. (Key column= Col2).
B) Use create key change column = True in sort stage
3. Pass the link to transformer
A) Create a stage variable SV1= If KeyChange=1 Then 1 Else SV1+1
B) Pass first 2 columns as output. (Map directly)
C) Create a Col3 and Map SV1 to this column.
You will get required output..!!
Duplicate Occurrences Count...!
Input is like this:
Col1,Col2
1,a
2,b
3,a
4,b
5,a
6,a
7,b
8,a
Output is in this form with row numbering of Duplicate occurrences.
Output:
Col1,Col2,Col3
"1","a","1"
"6","a","2"
"5","a","3"
"8","a","4"
"3","a","5"
"2","b","1"
"7","b","2"
"4","b","3"
Solution 1 :
Source => Sort =>Transformer=>Output
1. Read the source data.
2. A) Sort the source data on Col2. (Key column= Col2).
B) Use create key change column = True in sort stage
3. Pass the link to transformer
A) Create a stage variable SV1= If KeyChange=1 Then 1 Else SV1+1
B) Pass first 2 columns as output. (Map directly)
C) Create a Col3 and Map SV1 to this column.
You will get required output..!!
No comments:
Post a Comment