Accumulated Total

  
Hi

I have a cheque book type grid in my application.

Please could someone tell me how I can implement an accumulated total.

eg

Thing              Amount        Balance (accumulated total)
---------------------------------------------
Groceries           200             200
Computer          1,000          1200
Kitchen              4,999          6199

Cheers
Jon

The first issue is that you need some field to determine the order of the records, otherwise you can get different totals each time.  Typically this would be a date field, like in a checkbook application, but can be anything really.

Once you have that you need to use an advanced query to create the total column.  Unfortunately I do not have the time to figure this out but a number of possible solutions can be found on this thread - http://stackoverflow.com/questions/860966/calculate-a-running-total-in-sql-server.   If I find some time I'll look at this again.

If you do get something working please post here as I'm sure many other people would like to know this.

Hope this helps,
Curt
Hi

Thank you for your reply. The reason I asked is that I have evaluated a number of products and none of them can do an accumulated total well. It is part of my proof of concept as it is a key part of my main screen. I am develeoping a type of accounting system.

I also want a spreadhseet-like look - where a new transaction can be entered like spreadsheet at the bottom not in a standard  form.

On other products. The best result I have had is limiting the sort to date (not what I want). Calculating on row render. (can be done in SQL but that is a mess). Followed by refresh of the whole grid when a line changes.

I will be trying and will share what I manage to do. I hope I manage it. :)

Cheers
Jon