Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQl Calculate running totals on aggregate

Posted on 2008-10-06
5
Medium Priority
?
339 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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 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