Use a subquery to get the value from the previous row. Once you have that
value you can extract it from the current row in order to get the
difference.
The question arises as to how you define "previous". The example below
assumes there is an AutoNumber field named ID as well, so you can sort by
this number to define the order of the records:
SELECT [Col 1],
[Col 1] - (SELECT TOP 1 Dupe.[Col 1]
FROM Table1 AS Dupe
WHERE Dupe.ID > Table1.ID
ORDER BY Dupe.ID) AS Variation
FROM Table1
ORDER BY ID;
If subqueries are new, see:
How to Create and Use Subqueries
at:
http://support.microsoft.com/?id=209066
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Gama said:
I've a column with values and I want another column with the calculation
of
the difference between the current and the previous column, something like
this:
col 1 variation (from rows of column 1)
10 10
40 30
60 20
Is this possible with a simple expression? Tks in advance