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: How to show a select in one row

Re: How to show a select in one row

From: Nuno Souto <nsouto_at_nsw.bigpond.net.au.nospam>
Date: Wed, 8 Sep 1999 00:45:00 +1000
Message-ID: <7r3998$9sp$2@m2.c2.telstra-mm.net.au>


Another option if the number of rows is small is to join the table to itself. Then use a predicate to pick only row one of first table, row two of second table, and so on.

--
Cheers
Nuno Souto
nsouto_at_nsw.bigpond.net.au.nospam
Is there a nospam domain?
http://www.users.bigpond.net.au/the_Den Brian Peasland <peasland_at_edcmail.cr.usgs.gov> wrote in message news:37D51FA8.AB098C7A_at_edcmail.cr.usgs.gov...
> What you want to do is to turn a table on it's side. This can be found
> in Oracle, The Complete Reference by Oracle Press. To do this, you need
> to use the DECODE function. But with the DECODE function, you need to
> know the possible values that you might return. For instance,
>
> SELECT DECODE(id,'1','1',NULL) AS "1",
> DECODE(id,'2','2',NULL) AS "2",
> DECODE(id,'3','3',NULL) AS "3"
> FROM toto;
>
> would return
>
> 1 2 3
> --- --- ---
> 1
> 2
> 3
>
>
> This isn't quite what you are looking for, but it shows some of the
> "power" of the decode statement (as well as it's weaknesses).
>
> HTH,
> Brian
>
>
> Jorge wrote:
> >
> > something like this:
> > select * from toto
> > id
> > ---
> > 1
> > 2
> > 3
> >
> > select * from toto
> > id
> > ---
> > 123
Received on Tue Sep 07 1999 - 09:45:00 CDT

Original text of this message

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