Hi All,
I know there are tons of topic's on reverse pivoting but then i didn't get any clear understanding on the solution. Can any please help me out on my issue.
Input :
ID Name
1 John
1 Mike
2 Rita
2 Ray
1 Boy
Output :
ID Name1 Name2 Name3 Name4
1 JOHN MIKE BOY NULL
2 RITA RAY NULL NULL
I guess this can be achieved using stage variable's but not sure how to do...can someone please help me out...
Thanks in advance
Vertical Pivot
Moderators: chulett, rschirm, roy
Any chance you could use a Server job for this? That would make it trivial. Otherwise you need sorted input & group change detection via stage variables to perform this feet, that and probably a known 'end of data' record added to the stream to pop out the last group.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
ray.wurlod
- Participant
- Posts: 54595
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Sort by ID, generating a key change column.
Based on the key change value, in a Transformer stage either accumulate a delimited list of values or begin a new record.
Downstream of the Transformer stage use a Remove Duplicates stage to preserve only the last of each group.
You're pretty much done at this point. You could write to a CSV file directly. Otherwise you may need to re-parse the data (Column Input stage or Transformer stage) into your arbitrary number of output columns. Of course, the smart approach is to have "sufficient" columns for all cases and populate the remainder after parsing the ones you have with "" or NULL.
Based on the key change value, in a Transformer stage either accumulate a delimited list of values or begin a new record.
Downstream of the Transformer stage use a Remove Duplicates stage to preserve only the last of each group.
You're pretty much done at this point. You could write to a CSV file directly. Otherwise you may need to re-parse the data (Column Input stage or Transformer stage) into your arbitrary number of output columns. Of course, the smart approach is to have "sufficient" columns for all cases and populate the remainder after parsing the ones you have with "" or NULL.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
