Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Need help/hint creating a quiry
> Hi all
>
> Lets say I have a table:
>
> f1 char(10)
> f2 char(2)
> f3 number
>
> where f1 is a name, f2 is a code and f3 is a number.
>
> What I want to produce is a report that looks
> something like this:
>
> F1 F2 IS A F2 is B F2 IS C .... F2 is X
>
> f1 f3 f3 f3
> f1 f3 f3 f3 (different f1 )
> etc.
>
> So I want to transpose the table. I haven't done that
> before. Is there a way to do this assuming that the
> number of distinct values in f2 can be changed at any
> time (and therefore the number of columns in my report
> can vary)?
>
> thanks for any help
>
>
The only way to have a varying number of columns is to build the query dynamically and execute it in a PL/SQL block. When the number of columns is fixed, decode() usually is the solution. I'd rather change the specs.
Regards,
Stephane Faroult
Oriole Corporation
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Stephane Faroult INET: sfaroult_at_oriolecorp.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Tue Jun 26 2001 - 03:12:09 CDT
![]() |
![]() |