Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count last value + next value and so on 2

Status
Not open for further replies.

TanTrazz

Programmer
Aug 18, 2001
54
NL
Hi All,

Im creating a graph in asp.

What i want to do is count the previous value + next value and so on.

Example:

------------------------------
| ID | Name | Price |
------------------------------
| 1 | cars | 122 |
| 2 | toys | 90 |
| 3 | games | 240 |
------------------------------

What i want is :

the first spot in the graph is 122
the next one is 122+90 = 212
the next one is 212 + 240 = 452
etc.
etc.

Can someone help me with a script or example?

tnQ TanTrazz

 
maybe a loop through the values
Code:
do while not rs.eof
  firstvalue=rs("price")
  rs.movenext
  total = firstvalue + rs("price")
  response.write(total & "<br />")
loop

}...the bane of my life!
 
Try searching the database forums and google on "running total" ... there is more than one way to do it in a stored procedure and some tricks that work with certain databases but not others.
 
this can be easily done at the sql level...

you are just looking for a running total...

let me search for the code in my repository and get back to you...

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top