Simple math

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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.
 
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
 
Back
Top