A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Add a running sum column in a query



 
 
Thread Tools Display Modes
  #1  
Old February 20th, 2007, 03:30 AM posted to microsoft.public.access.queries
[email protected]
external usenet poster
 
Posts: 1
Default Add a running sum column in a query

I am having trouble adding a column in a query which is a running
total of my records.

Example:

Table 1 Column 1 has a data in each row as 1, 2, 3, 4, 5.

Now i want to add a column in a query which gives me the data of
column 1 and column 2 should be running total as 1, 3 (1+2), 6(1+2+3),
10 (1+2+3+4).

  #2  
Old February 20th, 2007, 01:33 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Add a running sum column in a query

This can be done, if you have a way of ordering the records that will give
unique position in the order for each record.

With the limited data you have given us there is no way to know the order of
the records. The following would work to give you a running sum if there
are no duplicate numbers in the column1. If there are duplicate numbers
then you would get the same running sum for the duplicates.

SELECT Column1,
(SELECT Sum(Column1)
FROM Table1 as T
WHERE T.Column1 = Table1.Column1) as RunningSum
FROM Table1
ORDER BY Column1



--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

wrote in message
ups.com...
I am having trouble adding a column in a query which is a running
total of my records.

Example:

Table 1 Column 1 has a data in each row as 1, 2, 3, 4, 5.

Now i want to add a column in a query which gives me the data of
column 1 and column 2 should be running total as 1, 3 (1+2), 6(1+2+3),
10 (1+2+3+4).



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.