Page 1 of 1
Converting rows into columns
Posted: Tue Jan 13, 2009 10:37 pm
by divine
Hi,
I have got a sequential file having 10 records into it. I want to transpose the recordset. How it can be done. For eg I ve got the following records at the input -
1 AA
2 BB
3 CC
The output should be -
1 2 3
AA BB CC
Please let me know how it can be done.
Thanks in advance,
Arindam.
Posted: Tue Jan 13, 2009 11:41 pm
by ray.wurlod
Search for "vertical pivot", for it is that which you are striving to accomplish.
Posted: Thu Feb 11, 2010 2:23 am
by abhishekachrekar
Hi Ray,
Can we use vertical pivot when we dont know the number of rows?
Eg
My file contains
1 AA
2 BB
3 CC
.
.
.
<N> LMT
Where <N> is any integer value.
Actually my requirement is as follows.
My file contains following recs.
A1 1
A2 2
A3 3
A4 4
A5 5
Now I have to generate following recs in addition to the above recs.
B1 A1(value)/A3(value)
B2 A2(value)/A4(value)
now A1(value) is the col2 value corresponding to A1 in the input file.
Since it is difficult to do calculations on data in different rows, I thought of transposing the rows to columns. But since the number of rows are not known I find it difficult to transpose it.
Kindly advise if there is any other way to achieve the result.
Regards,
Abhishek
Posted: Thu Feb 11, 2010 4:52 am
by ray.wurlod
This is very easy to do in a server job. Are you prepared to go that route?
Write into a hashed file or UniVerse table normalized on a multi-valued field then read it back un-normalized, converting the value marks (@VM) to whatever delimiter you require.