View Single Post
  #2  
Old February 20th, 2007, 12: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).