Access - querys

S

Sérgio Aires

Hi!
How can I subtract two values from the same column but from different rows?
I pretend to perform a query that has 10 registrations in the same column
and I want the result from the difference between the 2nd line and the 5th
line.
thanks!
 
J

John Vinson

Hi!
How can I subtract two values from the same column but from different rows?
I pretend to perform a query that has 10 registrations in the same column
and I want the result from the difference between the 2nd line and the 5th
line.
thanks!

You're assuming that tables have line numbers.

THEY DON'T.

A relational table *is not a spreadsheet*; you can reference other
records within a table only if you can use some field within the table
to select the record.

What is the actual structure of your table? What fields does it
contain?

John W. Vinson[MVP]
 
S

Sérgio Aires

My previous problem is in a query I have two columns and various
registrations. To be easier to understand I will call the columns A and B.
So what I need is B2 = A2+B1; B3 = A3+B2; etc.. How can I do this in Access.
thanks

--
Sérgio Aires
Lisboa
Portugal


"John Vinson" escreveu:
 
J

John Vinson

My previous problem is in a query I have two columns and various
registrations. To be easier to understand I will call the columns A and B.
So what I need is B2 = A2+B1; B3 = A3+B2; etc.. How can I do this in Access.
thanks

This sounds like a spreadsheet operation. A relational table may look
like a spreadsheet, but it is NOT one. Records in a Table ARE NOT like
rows in a spreadsheet; there is no concept of "the previous row".
Records in a Table are like potatoes in a bag - each is independent.

If you have some field in the record which (reliably - an AUtonumber
will not work because it may have gaps) distinguishes "the previous
record", you can create a Self Join query. Add the table to the query
window twice; the SQL would be something like

SELECT <whatever>
FROM Table AS TableA INNER JOIN Table AS TableB
ON TableB.SEQ = TableA.SEQ + 1

But storing derived data (it looks like you're trying to store a
running sum) in a table at all is not good design.

John W. Vinson[MVP]
 
S

Sérgio Aires

hi
I'm sorry but I can't to do this example..
My example is to control diesel registrations. If you send me your e-mail, I
will send you more information abou this case to better understand
thanks

--
Sérgio Aires
Lisboa
Portugal


"John Vinson" escreveu:
 
J

John Vinson

hi
I'm sorry but I can't to do this example..
My example is to control diesel registrations. If you send me your e-mail, I
will send you more information abou this case to better understand
thanks

I will be glad to send you my resume with my consulting terms. Private
EMail support is available for paying customers; these newsgroups are
for free support. Interested? If so please email me directly at
jvinson <at> wysardofinfo <dot> com. If not please explain why my
example doesn't work.

John W. Vinson[MVP]
 
Top