Simple math

C

Chrisg

How can I subtract a field in one record from the same field in the previous record? The primary key is set to be an auto number

I hope this is something easy that I'm just not seeing

Thanks.
 
G

Gerald Stanley

Here is a piece of SQL that may be of use to you

SELECT T1.tableId, T1.valueField, T1.valueField -
T2.valueField AS SubtractValue
FROM YourTable T1, YourTable T2
WHERE T2.tableId IN (SELECT TOP 1 tableID FROM YourTable T3
WHERE T3.tableId < T1.tableId ORDER BY T3.tableId DESC)

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
How can I subtract a field in one record from the same
field in the previous record? The primary key is set to be
an auto number.
 
R

Rick Brandt

chrisg said:
I appreciate the response. I'm not a SQL guy and this is for a non-server
application. I am assuming that a server is required to use SQL, right? If
know I'm not sure where to place this code. If it is required, is there an
alternative that doesn't.

You've created a query or two in your apps right? Open one up and look at
the toolbar. You have three choices for "View".

Datasheet
Design
SQL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top