August 20, 2008 at 4:05 pm
Hi:
I have some table data, each row containing a key column and a column indicating a duration in minutes, like so:
[font="Courier New"]EventKey Duration
1 10
2 20
3 30
4 40[/font]
I'd like to run a query that returns the key along with a cummulative duration. In other words, how much time has passed after each consecutive event has run. The result set would like like this:
[font="Courier New"]EventKey Duration
1 10
2 30
3 60
4 100[/font]
After all the events run, 100 minutes will have passed. The rows will always be adjacent. The SUM() function only works for the row total. I need them after each. Can somebody provide some script that might do the trick? Thanks.
August 21, 2008 at 6:11 am
This is a Running Totals problem. Check out this article, http://www.sqlservercentral.com/articles/Advanced+Querying/61716/.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 21, 2008 at 11:00 am
Thanks for the pointer.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply