I am running an oracle 10g database.
I am selecting values from different columns of the database and summing them together to produce a new column entirely. The summation involves manipulating different no. of columns based on the month of the year i am dealing with. I start with month 12 and sum all the 12 column values, when i get to 11, the columns reduce again until i finally get to one which leaves me with only one column value (see below). I feel there should be a simpler way of doing it than going through the routine i have below, reducing all the column values as the month changes.
Please can someone advice on best solution ASAP.
The tables were originally a mainframe flat file structured one. It was later migrated to oracle and since the mainframe structure was not an RDBMS structure. The columns were migrated that way because it was like an array kind of thing in the mainframe environment
so wahts the solution
I forgot to mention ... if you have to write more than one (this particular one) query using the same data set, perhaps you might want to create a VIEW and, in the future, use this "nicely formatted" view as a data source.