Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Crosstable (Pivot Table)
On Mon, 9 Mar 1998 19:37:51 +0100, "Dauner Jürgen" <Juergen:dauner_at_allgaeu.org> wrote: Hi,
imaging a table containing regions:
region:
region_id region_name
1 Allgaeu 2 Franken 3 Baden
Another on with cars:
car_type car_modell
1 Golf 2 Mercedes 500 SEL 3 Porsche 911 Targa
A thirdr one containing sold cars per day in each region:
sale:
region_id car_type day_of_sale
1 2 03/23/1998 3 24 04/01/1998
to get a pivot table that sums sold car_modells per region:
Select
car_type, sum(decode(region_id,1,1,0)) 'Allgaeu', sum(decode(region_id,2,1,0)) 'Franken', sum(decode(region_id,3,1,0)) 'Baden',
sale
group by car_type;
>Hy,
>A few days ago, I changed my database from MS-Access toOracle Workgroup
>Server. In my Access DB i have a view created which changes the rows into
>colomns, in german a so called Kreuztabelle (cross table ???). If I look at
>the SQL Statement there is a "pivot" statement which does this job. In
>Oracle there must be an equivalent statement but which on is it ?
>Who can help me ?
>
>Juergen.Dauner_at_multivac.de
>Juergen.Dauner_at_allgaeu.org
>
>
>--
>-----
>This Message was send via Microsoft Mail and News
>
>
-- Regards Matthias Gresz :-) GreMa_at_T-online.deReceived on Tue Mar 10 1998 - 00:00:00 CST