Avatar of Sivasan
Sivasan
Flag 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
Microsoft Access

Avatar of undefined
Last Comment
Gustav Brock

8/22/2022 - Mon
Paul Neralich

Sivasan,

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

- Paul N.
PatHartman

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
Gustav Brock

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Sivasan

ASKER
Hi Gustav Brock,
Thank you very much. This is what I was looking for worked
Thank you
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Gustav Brock

You are welcome!
PatHartman

Thanks for providing the fish Gus just in case the OP couldn't figure out my instructions.
Gustav Brock

You are welcome!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.