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

Home -> Community -> Usenet -> c.d.o.misc -> Re: pivoting tables into columns

Re: pivoting tables into columns

From: ianal Vista <ianal_vista_at_hotmail.com>
Date: Sat, 01 Jul 2006 01:00:39 GMT
Message-ID: <Xns97F2B73AC3593ianalvistahotmailcom@70.169.32.36>


"Alexander Birch" <abirch_at_gmail.com> wrote in news:1151706882.115058.270540_at_d30g2000cwa.googlegroups.com:

> What would be the best way to approach the following problem? Would it
> be to use sql to obtain the data, then manipulate it with a procedural
> lanugage? Or would is it possible to do this with pure sql.
>
> there are three tables
> test1, test2, test3
>
> in each of these tables I have different samples
> sample1, sample2, sample3, sample4
>
> in test1 I have the following
> ---------------
> sample1 result1a
> sample1 result1b
> sample2 result1a
> sample4 result1a
>
> in test2
> sample1 result2a
> sample2 result2a
> sample2 result2b
> sample3 result2a
>
> in test3
> sample1 result3a
> sample3 result3a
> sample3 result3b
> sample3 result3c
>
>
> is there anyway in sql (including pl/sql) to do the following
>
> sample | Test1 | Test2 | Test3
> ----------+------------+------------+-----------
> sample1 | result1a | result2a | result3a
> ----------+------------+------------+-----------
> sample1 | result1b | |
> ----------+------------+------------+-----------
> sample2 | result1a | result2a |
> ----------+------------+------------+-----------
> sample2 | | result2b |
> ----------+------------+------------+-----------
> sample3 | | result2a | result3a
> ----------+------------+------------+-----------
> sample3 | | | result3b
> ----------+------------+------------+-----------
> sample3 | | | result3c
> ----------+------------+------------+-----------
> sample4 | result1a | |
> ----------+------------+------------+-----------
>
>

GOOGLE is your friend, but only if you use it.

http://asktom.oracle.com -- has many fine coding examples. Received on Fri Jun 30 2006 - 20:00:39 CDT

Original text of this message

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