Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: cross-tab querie
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
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
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