Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Question - Transpose rows to columns
George Dimopoulos <george_at_cheos.ubc.ca> wrote in message
746ije$p0p$1_at_nntp.ucs.ubc.ca...
>Are you able to transpose rows to columns easily with a single sql
>statement?
>
>example
>
>
>select id, (select value from lab where code = 'HG' AND patient_id =
>l.patient_id(+)) HG,
> (select value from lab where code = 'CR' and patient_id =
>l.patient_id(+) CR
>from lab l
>
Noway!
The only thing you can do is to join several times the same table like this:
select t1.col, t2.col, t3.col
from table t1, table t2, table t3
where t1.id = t2.id and t1.id = t3.id
(... or you can specify you own where condition)
Regards, Sergey Received on Thu Dec 03 1998 - 16:20:48 CST