Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Crosstab with Oracle SQL, PL/SQL
Check the DECODE expression. The documentation has an example to do
what you want something like :
select country,decode(year,1997,amount,0) as y1997,
decode(year,1998,amount,0) as y1998...
You can use this as a subselect and:
select country,sum(y1997),.. from (subselect) group by country
or something similar.
HTH Ted
On Thu, 07 Dec 2000 14:43:56 +0100, chris <dawnchri_at_gmx.de> wrote:
>Hello,
>
>does anybody can give me an easy example in Oracle SQL, PL/SQL of a
>'crosstable' like following,
>
>from...
>
>USA 1997 44
>China 1997 64
>Canada 1997 13
>USA 1998 47
>China 1998 78
>Canada 1998 97
>
>
>to...
>
> 1997 1998
>USA 44 47
>China 64 78
>Canada 13 97
>
EMail: knijff_at_bigfoot.com Received on Sat Dec 09 2000 - 06:45:03 CST
![]() |
![]() |