Link to home
Start Free TrialLog in
Avatar of Sivasan
SivasanFlag for United States of America

asked on

Sum the all the above rows of a field on another field in access query

I have an access table with field ID, Item NoofHour this in sequence I like the keep summing the NoofHours
so table Order
id  Item  Hours
1    abc    5
2    ccc    10
3    yyy    2
4   kka     3

I want to make query so result are
id  Item  Hours   Totalhr
1    abc    5             5                
2    ccc    10           15                
3    yyy    2             17
4   kka     3             20

So add the above hours. I will appreciate if somebody can tell me how I can get  sum  of row above.
Thanks
Avatar of Paul Neralich
Paul Neralich
Flag of United States of America image

Sivasan,

I think you are describing a "running total". Can you share the query that you have written so far?

- Paul N.
A running total is a trivial process in a report.  You just use the RunningSum() property to create the value.

However, it is much more of a problem in a query and it is also very inefficient and so may be extremely slow.  The most efficient method is to do a self- join and sum all the rows with a PK <= the current one.  This of course only works if you actually have a numeric uniqueID that is ascending.
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sivasan

ASKER

Hi Gustav Brock,
Thank you very much. This is what I was looking for worked
Thank you
You are welcome!
Thanks for providing the fish Gus just in case the OP couldn't figure out my instructions.
You are welcome!