Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Transpose rows to columns
In article <7441pf$3ki$1_at_nnrp1.dejanews.com>,
abhijitde_at_my-dejanews.com wrote:
> Hi everybody,
>
> Can anybody look into my problem? The problem is to transpose columns to rows
> dynamically.
>
> The original table is -
>
> Proj Prot Pid Labcode Result
> 001 1 1 HGB 100.00
> 001 1 1 RBC 200.00
> 001 1 1 HCT 300.00
> 001 1 2 HGB 150.00
> 001 1 2 HCT 112.00
> 001 1 2 RBC 150.00
> 001 1 2 XYZ 102.00
>
> So, there could be say 50 labcodes vertically for each pid.
>
> Now, the above has to be transposed to -
>
> Proj Prot Pid HGB RBC HCT XYZ
> 001 1 1 100.00 200.00 300.00 Null
> 001 1 2 150.00 150.00 112.00 102.00
>
> Any help/hints is appreciated.
>
> Thanks!
>
> Abhijit
Several possibilities.
One use a matrix report in SQL ReportWriter 2.X. This is practically a gimee.
Two is write a PL/SQL procedure to collect the columns and then the data and output the information to a file. More work but doable.
Three output the results as is and use some other tool to transpose the data. I have a simple report like this with 20K rows. I was able to write a short perl script, to determine the number of columns, and transpose the data -- skipping missing cells as needed. More steps but still doable.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
--
Michael Krolewski
mikkro_at_hbsi.com
All opinions are my own, and do not represent my employer.
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Thu Dec 03 1998 - 02:43:47 CST
![]() |
![]() |