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 creat a Pivot Table with Oracle8

Re: how to creat a Pivot Table with Oracle8

From: Steve McDaniels <steve.mcdaniels_at_sierra.com>
Date: Fri, 29 Oct 1999 11:08:06 -0700
Message-ID: <7vcnsu$12m$1@plo.sierra.com>


(This is why I continue to use Access)

You must first obtain a list of all of the subordinate column names.

Then you must (manually) construct the crosstab yourself using the Oracle function DECODE

Assume table T:

F1 number
F2 varchar2(..)

(All) Possible values values for F2 are V1, V2, V3, ... Vn

select

    F1,
    count(*) total,

    sum(decode(F2,V1,1,0)) V1,
    sum(decode(F2,V1,1,0)) V2,
    sum(decode(F2,V1,1,0)) V3,

    :
    sum(decode(F2,V1,1,0)) Vn
From T
Group by F1

This produces the ouput:

F1 Total V1 V2 V3 ... Vn ---- ------ --- --- --- --- ---

 xx    xx        xx        xx       xx        xx
xx    xx        xx        xx        xx        xx
etc.

(bites, doesn't it?)

Michaela Weber <weberm68_at_hotmail.com> wrote in message news:7v9bvq$8lm$1_at_news.imp.ch...
> Hello there...
>
> Does anybody has a idea how to creat an PivotTabel with Oracle8
>
> There are two linked table 1:n . In Access it works very well (with the
> wizzard)...but I have no idea how I can do it in ORACLE
>
> thanks
>
> Michaela
>
>
>
Received on Fri Oct 29 1999 - 13:08:06 CDT

Original text of this message

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