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: Pivot in Oracle SQL

Re: Pivot in Oracle SQL

From: Bippie <no.spam_at_for.me>
Date: 28 May 1998 15:51:45 GMT
Message-ID: <6kk16h$5gl$1@hdxf08.telecom.ptt.nl>


Hi David,

As far as I know the only way to create an output like this is when you have a constant number of winetypes.

It seems you have found it out yourself already, but here's the statement to do it.

select wine

,      decode(type,'Dry',1,null) "Dry"
,      decode(type,'Half dry',1,null) "Half dry"
,      decode(type,'Sweet',1,null) "Sweet"
from winecellar
order by wine
/

(not tested)

If you have found a solution already (but I doubt there is any), I would be glad if you could share it with us.

Greetz,

Bippie

David Zetterlund <tu.stddz_at_memo.volvo.se> schrijfbewerkingen: > Hello!
>
> In MS SQLServer I can use the keywords TRANSFORM and PIVOT. How do I get
> the corresponding functionality in Oracle SQL ?
>
> Ex.
>
> TABLE Winecellar:
>
> Wine Type
> """"""""""""""" """"""""
> Snake Wine Half dry
> Franco Blanc Dry
> Sweet Snake Sweet
> Belle Madame Dry
> California Sun Dry
>
>
> VIEW Type:
>
> TRANSFORM Sum(1) AS iValue
> SELECT Winecellar.Wine
> FROM Winecellar
> GROUP BY Winecellar.Wine
> PIVOT Winecellar.[Type];
>
> displays:
>
> Wine Dry Half dry Sweet
> """""""""""""" """""""""""""" """""""""""""" """"""""""""""
> Belle Madame 1
> California Sun 1
> Franco Blanc 1
> Snake Wine 1
> Sweet Snake 1
>
>
> If the number of winetypes is constant then there's no problem, but if
> they aren't...
>
> In need of help!
>
> David
Received on Thu May 28 1998 - 10:51:45 CDT

Original text of this message

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