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

Re: How to show a select in one row

From: Brian Peasland <peasland_at_edcmail.cr.usgs.gov>
Date: Tue, 7 Sep 1999 14:22:32 GMT
Message-ID: <37D51FA8.AB098C7A@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

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:22:32 CDT

Original text of this message

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