Ok I have the following variables
Discount Rate (R) - A static user defined value
demand (D) - the result of a query
base year (Y1) - 2003
future year (Y2) - user entered and needs to count backward to base year
I need the following formula to execute
NPD = D/ (1+R)^(Y2-Y1)
and iterate over taking 1 off of the Y2 value until until (which the user entered) = Y1 (2003). Each time it iterates it needs to go off and select D again based on the new iterated smaller value of Y2, figure out NPD and add the value to the earlier one.
So if the user enters 2009 for Y2 the query needs to go and run the select statement I build for D and then use that to figure out NPD, ie NPD = D/ (1+R)^(2009 - 2003).
Then it needs to set Y2 to to 2008 and recalculate NPD in the same manner.
Each value for NPD needs to be stored and added to the others. So if it iterates 8 times I need the result to be the sum of the 8 iterations.
Complex enough? I'm working with SQL in Oracle/ HTMLDB/ Application Express. Anyone help me here?
Thanks, Michael
Discount Rate (R) - A static user defined value
demand (D) - the result of a query
base year (Y1) - 2003
future year (Y2) - user entered and needs to count backward to base year
I need the following formula to execute
NPD = D/ (1+R)^(Y2-Y1)
and iterate over taking 1 off of the Y2 value until until (which the user entered) = Y1 (2003). Each time it iterates it needs to go off and select D again based on the new iterated smaller value of Y2, figure out NPD and add the value to the earlier one.
So if the user enters 2009 for Y2 the query needs to go and run the select statement I build for D and then use that to figure out NPD, ie NPD = D/ (1+R)^(2009 - 2003).
Then it needs to set Y2 to to 2008 and recalculate NPD in the same manner.
Each value for NPD needs to be stored and added to the others. So if it iterates 8 times I need the result to be the sum of the 8 iterations.
Complex enough? I'm working with SQL in Oracle/ HTMLDB/ Application Express. Anyone help me here?
Thanks, Michael