We help IT Professionals succeed at work.

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

Sivasan
Sivasan asked
on
73 Views
Last Modified: 2018-09-25
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
Comment
Watch Question

Paul NeralichIT Specialist
CERTIFIED EXPERT

Commented:
Sivasan,

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

- Paul N.
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
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.
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Hi Gustav Brock,
Thank you very much. This is what I was looking for worked
Thank you
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You are welcome!
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:
Thanks for providing the fish Gus just in case the OP couldn't figure out my instructions.
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You are welcome!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.