Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: cross-tab querie

Re: cross-tab querie

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Fri, 26 Jun 1998 21:06:22 GMT
Message-ID: <35940cfb.1492956@192.86.155.100>


A copy of this was sent to "Herve Meftah" <hm89659_at_GlaxoWellcome.co.uk> (if that email address didn't require changing) On 26 Jun 1998 16:28:27 GMT, you wrote:

>Hi,
>I need to write a cross-tab querie on ORACLE, I known it's quite simple
>but my SQL is a few rusty, (I've got a better skills on Transact-SQL
>Sybase).
>
>The problem is :
>
>TABLE A
>year period amount
>1990 1 125
>1990 2 130
>1990 3 150
>1991 1 160
>......
>

select year,

       sum( decode( period, 1, amount, 0 ) ) period_1,
       sum( decode( period, 2, amount, 0 ) ) period_2,
       sum( decode( period, 3, amount, 0 ) ) period_3,
       sum( amount ) total

from table_a
group by year

will do it...

>Result TABLE
>year periode_1 periode_2 periode 3 total
>1990 125 130 150 405
>1991 160 ....
>
>I guess the syntax it's not the same between ORACLE and SYBASE
>
>Thanks
>
>
>
>
>
>
>
>
>
>
>
>
>
>
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Fri Jun 26 1998 - 16:06:22 CDT

Original text of this message

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