troubleshooting Question

SQL Server Running Balance

Avatar of gdemaria
gdemariaFlag for United States of America asked on
Microsoft SQL ServerSQL
9 Comments1 Solution94 ViewsLast Modified:
I think I need a cursor for this, but just wanted to check to see if any new features would make this possible.

I have a table with a date and a value, the value ends with the rest null.
I'd like to fetch the 1000 initial value and do some math on it, then save that result into the next record (1/2) and then take that value and do some math and save it to the next record and so on..

Update myTable
   set  value =  (previousTotal + column2 * aFunction( rand() ) )

Date ...   Value
1/1         1000
1/2         NULL
1/3         NULL
1/4         NULL

Cursor required?
ASKER CERTIFIED SOLUTION
Mark Wills
Topic Advisor
Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros