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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Is this possible in Oracle SQL?

Re: Is this possible in Oracle SQL?

From: Jonathan Gennick <jonathan_at_gennick.com>
Date: 2000/06/01
Message-ID: <qmbdjsg52qu0hp6k41u0384u5lpv3h19mc@4ax.com>#1/1

On Thu, 1 Jun 2000 11:44:42 +0100, "A D Kendall" <nobody_at_nowhere.com> wrote:

>i.e. the data in the ANALYSIS_CODE field in the detail table becomes the
>heading of a column in the results and the associated ANAL_TOTAL becomes the
>data of this column.
>
>Is this possible in Oracle 8i ? I am lead to believe it is possible in MS
>Access using a TRANSPOSE keyword (or similar) in the SELECT statement.

If you are dealing with a fixed number of analysis codes, you can use the DECODE function to achieve the behavior that you are looking for. For example:

select decode(analysis_code,'A',analysis_data,NULL) A

         decode(analysis_code,'B',analysis_data,NULL) B from your_table;

Since you need one expression in your SELECT for every column of output, you need to know in advance the number of columns that you are working with. This solution won't work if you have a potentially limitless number of analysis codes.

Jonathan



jonathan_at_gennick.com
http://gennick.com
Brighten the Corner Where You Are Received on Thu Jun 01 2000 - 00:00:00 CDT

Original text of this message

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