Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating running total

Status
Not open for further replies.

DonS100

Programmer
Dec 4, 2001
104
US
How do can you write a query to show a running total. If I had a table with
employee, date, amount how would I get a additional column to show the running total
Row 1 - Smith, 1/1/05, $500, $500
Row 2 - Smith, 1/8/05, $750, $1,250
Row 3 - Smith, 1/9/05, $100, $1,350

Thanks

Don
 
make a calculated control, tweak the field names as appropriate, something like this:

Code:
=Dsum("AmountFieldName","TableName","PersonNameField = '" & [PersonName] & "' and DateFieldName <= #" & [DateField] & "#")

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
SELECT A.Name, A.Date, A.Amount, Sum(B.Amount) AS Total
FROM yourTable AS A INNER JOIN yourTable AS B ON (A.Name=B.Name) AND (A.Date>=B.Date)
GROUP BY A.Name, A.Date, A.Amount
ORDER BY 1, 2;


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top