Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Help with select statement (pivot table?)
albundy1998_at_hotmail.com wrote:
> I know a little sql. A hint will probably suffice. Would like to see
> some sql though. I'm assuming this is possible then by your comments?
> I'm not using SQL*Plus nor Crystal. I'm using VBA/ODBC through Excel.
> Thanks...
>
> AL
>
> DA Morgan wrote:
>
>>albundy1998_at_hotmail.com wrote: >> >> >>>I'm a sql novice. I'm trying to write a financial report. I need
>>>sql statement that will add a range of fields (periods). See table
>>>example below.. >>> >>>Fields: Year, Account, Period1, Period2, Period3, ..., Period12 >>>Values: 2005, 12345, 100, 200, 300, ..., 1200 >>> >>>The user will pick the year, account, and any period range. For >>>example the user picks Year 2005, Account 12345, and wants periods
>>>12. Next time the user will want periods 1 - 3 or 6 - 8 or any
>>>of periods. I wonder if there's a sql statement to dynamically
>>>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 >>> >>>And then summing the Periods field if the period is between the
>>>the user wants. Any ideas on how to do this? >>> >>>TIA... AL >> >>And you are doing this in SQL*Plus or Crystal Reports or ....? And
>>version? >> >>Do you know SQL and you want a hint or are you looking for someone to
>>your work for you? >>-- >>Daniel A. Morgan >>University of Washington >>damorgan_at_x.washington.edu >>(replace 'x' with 'u' to respond)
Examples of DECODE and CASE used to pivot can be found at:
http://www.psoug.org
click on Morgan's Library
click on DECODE
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace 'x' with 'u' to respond)Received on Sat Apr 30 2005 - 09:23:09 CDT