?
Solved

SQl Calculate running totals on aggregate

Posted on 2008-10-06
5
Medium Priority
?
337 Views
Last Modified: 2011-10-19
In SQL How do I calculate the running totals on a field straight after (ie withingt the same sql function) it has been summed or counted. See attached example

test.xls
0
Comment
Question by:ulsterweavers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 32

Expert Comment

by:Daniel Wilson
ID: 22649802
Would be nicer in SQL Server ... but I think this will work in Access.

Select M.Booked, Sum(M.Moved) as Qty, 
  (Select Sum(Booked) From Moves Where Moves.Booked <= M.Booked) as Res
From Moves as M 
Group by M.booked
order by M.Booked

Open in new window

0
 

Author Comment

by:ulsterweavers
ID: 22650322
Yeah that's the one Daniel. Thank-you very much. Cant believe I was being so daft, I was using count (becase the moved was only going up or down by one each time) and always being slightly out, which made me question everything!!
0
 

Author Comment

by:ulsterweavers
ID: 22650356
oh its not giving me the option to accept and award points, is it because I posted a reply first? do you need to repost?
0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 22650368
At the bottom of my reply should be the Accept link.

glad to help ... I've fought w/ that type of problem enough that now I know the answer!
0
 

Author Closing Comment

by:ulsterweavers
ID: 31503383
thanks again Daniel!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question