Query to add 2 rows together

ARW17

Board Regular
Joined
Oct 31, 2016
Messages
109
This is hard to explain, but here goes:

Simplified Data:

ValueA ValueB
5 30
10 40
15 50
20 60

Can I write a query that would result in the following?
Expression1
10+30 = 40
15+40 = 55
20+50 = 70

I need to add the present row + the value of the row above it...

Thanks!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi, that is not generally an operation you'd do in a database. It might be possible if you have some key fields that provide order - such as a DateEntered field, or a sequential primary key field (but even then it might not be a very well performing operation). The basic problem is that how do you know that one row comes before another? In a spreadsheet, that makes sense, in a database it is not generally something you rely on.
 
Upvote 0
Not an easy task in Access. In Access, order of records within a table really has no meaning. Someone said it is best to think of an Access table as a bag of marbles (where the marbles are each record). they are all mixed up and jumbled up. This is because in a truly relational database, there should be any dependency or relationships between records in the same table.

There are a few ways to do what you want. One requires VBA. The other requires an ordering mechanism.
Here are a few articles that talk about these processes:
Calculations dependent on previous record - Access World Forums
Microsoft Access tips: Subquery basics
 
Upvote 0
Hi, that is not generally an operation you'd do in a database. It might be possible if you have some key fields that provide order - such as a DateEntered field, or a sequential primary key field (but even then it might not be a very well performing operation). The basic problem is that how do you know that one row comes before another? In a spreadsheet, that makes sense, in a database it is not generally something you rely on.

I do have time intervals:
6:00 AM
6:15 AM
etc...

So that's where I was trying to anchor it to.
 
Upvote 0
YOu would write a query with an expression that joins the row to the row with the next lowest number (or next higher number). But you can't have just times? There must be something else - a employee ID, transaction ID, or something ...
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top