Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Question - Transpose rows to columns

Re: SQL Question - Transpose rows to columns

From: Sergey Tavanets <Sergey_at_cu.kiev.ua>
Date: Fri, 4 Dec 1998 00:20:48 +0200
Message-ID: <7472t7$2pdm$1@whale.gu.net>

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US