Re: Matrix report in SQL*Plus
Date: 1997/07/30
Message-ID: <33DF5885.46F4_at_fyiowa.infi.net>#1/1
Try
SELECT sector,
sum(decode(country,'US',value,null)) US, sum(decode(country,'NL',value,null)) NL, sum(decode(country,'JP',value,null)) JPFROM table1
GROUP BY sector;
For each matrixed column you'll need a hardcoded decode statement. If It can't be hardcoded then use dynamic SQL.
Steve J
Per Elmgreen wrote:
>
> Hi,
>
> Does anyone have a smart technique for writing a sql-script to produce a
> matrix report from a single tables data. The table looks like this:
>
> Field 1 2 3
> Sector Country Value
> ------------------------------
> Banking US 12.6
> Banking NL 2.6
> Banking JP 8.6
> Industri US 10
> Industri NL 30
> Industri JP 45
>
> I would like the report to look like this
>
> US NL JP
> Banking 12.6 2.6 8.6
> Industri 10 30 45
>
> Any suggestions would be very appricated !
>
> Regards,
>
> Per Elmgreen
Received on Wed Jul 30 1997 - 00:00:00 CEST