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: Help with select statement (pivot table?)

Re: Help with select statement (pivot table?)

From: Rene Nyffenegger <rene.nyffenegger_at_gmx.ch>
Date: Fri, 29 Apr 2005 07:40:10 +0000 (UTC)
Message-ID: <d4socq$sbk$2@klatschtante.init7.net>


On 2005-04-28, albundy1998_at_hotmail.com <albundy1998_at_hotmail.com> wrote:
> I'm a sql novice. I'm trying to write a financial report. I need a
> sql statement that will add a range of fields (periods). See table and
> example below..
>
> Fields: Year, Account, Period1, Period2, Period3, ..., Period12
> Values: 2005, 12345, 100, 200, 300, ..., 1200

Why don't you post the create table and insert SQL statement here. It makes things much easier.

> The user will pick the year, account, and any period range. For
> example the user picks Year 2005, Account 12345, and wants periods 1 -
> 12. Next time the user will want periods 1 - 3 or 6 - 8 or any range
> of periods. I wonder if there's a sql statement to dynamically handle
> this.
>
> I'm thinking about creating a pivot table to rearrange the data to:
>
> Year, Periods, Amounts
> 2005, Period1, 100
> 2005, Period2, 200
> 2005, Period3, 300
> ...
> 2005, Period12, 1200

Look into case when ... then ... else if ... then [...] else ... end

> And then summing the Periods field if the period is between the range
> the user wants. Any ideas on how to do this?

-- 
  Rene Nyffenegger
  http://www.adp-gmbh.ch/
Received on Fri Apr 29 2005 - 02:40:10 CDT

Original text of this message

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