473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to start a running sum from other calculation

I have a query that creates a graph of bookings from the course start date
looking back 20 weeks based on a running sum.

I also have a query that counts the number of bookings before that 20 week
date for that particular course start date.

What they want is to start the 20 week running sum from the previous total.

for ex

start date = 1/11/2004
20 week before = 14/6/04
in my case I have sql returning:

Qrygetweeklycountofdosmodulesptb Week Commencing Total Bookings Running
Total Week Number
14/06/2004 0 0 -21
21/06/2004 4 4 -20
28/06/2004 2 6 -19
05/07/2004 3 9 -18
12/07/2004 3 12 -17
19/07/2004 3 15 -16
26/07/2004 3 18 -15
02/08/2004 2 20 -14
09/08/2004 6 26 -13
16/08/2004 6 32 -12
23/08/2004 8 40 -11
30/08/2004 1 41 -10
06/09/2004 2 43 -9
13/09/2004 0 43 -8
20/09/2004 0 43 -7
27/09/2004 0 43 -6
04/10/2004 0 43 -5
11/10/2004 0 43 -4
18/10/2004 0 43 -3
25/10/2004 0 43 -2
01/11/2004 0 43 -1
with total of bookings prior to 14/6/2004 of 26.

What they want is:

Qrygetweeklycountofdosmodulesptb Week Commencing Total Bookings Running
Total Week Number
14/06/2004 0 0 -21
21/06/2004 4 30 -20
28/06/2004 2 32 -19
05/07/2004 3 35 -18
12/07/2004 3 38 -17
19/07/2004 3 41 -16
26/07/2004 3 44 -15
02/08/2004 2 46 -14
09/08/2004 6 52 -13
16/08/2004 6 58 -12
23/08/2004 8 66 -11
30/08/2004 1 67 -10
06/09/2004 2 69 -9
13/09/2004 0 69 -8
20/09/2004 0 69 -7
27/09/2004 0 69 -6
04/10/2004 0 69 -5
11/10/2004 0 69 -4
18/10/2004 0 69 -3
25/10/2004 0 69 -2
01/11/2004 0 69 -1
Sorry for the overkill on info it just avoids mis interpretation.

I am not sure how this can be done so Ideas would be welcome.

Regards in advance
Peter

SQL:

first running sum:

SELECT Pro.[Week Commencing], Pro.[Total Bookings], (Select Sum(Pro1.[Total
Bookings]) from Qrygetweeklycountofdosmoduleenrollments Pro1 where
Pro1.[Week Commencing]<=Pro.[Week Commencing]) AS [Running Total], Pro.[Week
Number]
FROM Qrygetweeklycountofdosmoduleenrollments AS Pro
ORDER BY Pro.[Week Commencing];

Prior bookings:

SELECT Count(Qrygetpriorbookings.Date) AS [Prior Booking Count]
FROM Qrygetpriorbookings;


Nov 13 '05 #1
2 1733
there's an article in MSKB that shows how to do a running sum in a query.
Nov 13 '05 #2
I did that but I phrased the question incorrectly.

I want to start a running sum which I have done but I want to add another
total to the first row and only the first row and then subsequently do the
running sum form there.

I hope i explained that well enough.

regards
Peter
"Pieter Linden" <pi********@hotmail.com> wrote in message
news:bf**************************@posting.google.c om...
there's an article in MSKB that shows how to do a running sum in a query.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marc | last post by:
I want to write a C#/ASP.NET application where a user can go to a web page, start running a job, close their browser, and then come back later and see the results. The purpose for this application is...
0
by: Phil | last post by:
I recently replaced my Toshiba 6100 laptop running XP Pro with a Dell Latitude D810 running XP Pro; since that time an application that I developed over a year ago has stopped working. I am using...
8
by: Robert Megee | last post by:
I can't get Process.Start() to work from a Web application. Is this because of the security settings in the browser? Since this is for a private network, security isn't an issue. Anyone know how...
16
by: Serdar Kalaycý | last post by:
Hi everybody, My problem seems a bit clichè but I could not work around. Well I read lots of MSDN papers and discussions, but my problem is a bit different from them. When I tried to run the...
6
by: mg | last post by:
The following .exe and its parameters work correctly from the command prompt (it prints x.pdf without prompting the user. acrord32.exe /t "c:\exportfiles\x.pdf" "HP LaserJet 3300 Series PCL 6"...
6
by: kai | last post by:
Hi, I was tring to run an example (HelloWorld.aspx) from MSPrss book, I get this message: "ASP.NET Development Server faild to start listening port 1034. Error message: An attempt was made...
1
by: sgmarty | last post by:
Hi, I have an interesting problem. Without using reduncant data, how can I design a calculation field to get a running total from values in different records? I'm designing a usage/month report, and...
1
by: Colin Clark | last post by:
Hello, I have a database of scores for a sports club. I want to display a continuous subform showing a person's scores for the season along with a running calculation based on those scores (the...
53
by: yinglcs | last post by:
Hi, In java, there is an 'indexOf' function in String which does this: indexOf(String str) Returns the index within this string of the first occurrence of the specified substring. is there...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.