Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Help with select statement (pivot table?)
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
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
And then summing the Periods field if the period is between the range the user wants. Any ideas on how to do this?
TIA... AL Received on Thu Apr 28 2005 - 18:51:42 CDT