This content has been marked as final. Show 2 replies
There's a contradiction in your question. "then followed by the sum of number of all _PREVIOUS_ numbers _BEFORE_ that value.", and you're still giving "D / A + B + C + D" as an example. So, do you want to include the _current_ value or not?
Also, you're saying don't want the sum of all previous numbers, but the sum of _NUMBER_OF_ previous numbers? Eh?
So, first iteration would produce 1, the second 1+2, third 1+2+3, fourth 1+2+3+4, etc?
I'm puzzled, but maybe here's some help:
Assuming we use something like "SELECT databaseValue FROM myTable" ...
<CFSET sumOfPrevious = 0>
<CFSET sumOfPrevious = sumOfPrevious + databaseValue>
#databaseValue# / #databaseValue/sumOfPrevious#
If I got you wrong, and you want to divide the value by the sum of all _PREVIOUS_ numbers, move the <CFSET> after the <CFOUTPUT> line just before the </CFOUTPUT>, so that the result is printed out first.
If I got you wrong again, and you want to divide the value by the *sum* of _number_of_values_ (it's sounds insane, I know), increment the sumOfPrevious by #myQuery.currentrow# each time, instead of the databaseValue.
Thanks Fernis, the first one is the one that I wanted. Wanted to show the number on the left hand side followed by the sum of numbers of all the numbers of the previous row up to the current row. It worked fine.