Running Total

G

Guest

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
 
M

Marshall Barton

Don said:
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


Use a calulated field that consists of a subquery.

RunAmt: (SELECT Sum(Amt) FROM table As X WHERE X.date <=
table.date AND X.employee = table.employee)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top