Find the difference between 2 number in a column

namu

Registered User.
Local time
Today, 02:17
Joined
Dec 30, 2014
Messages
26
Hi Guys,

I need help/advice to create a query that will show the difference between the number on the first row and the next number below it and so on. Currently i have a query that calculates some data that is a result of a formula. I want to get the Diff Value just like the table below.

ID Data Value Diff Value
1 2 2
2 5 3
3 9 4
4 15 6
5 16 1

Thank you in advance.

namu
 
Allen Browne's Web Page on subquery has a section on getting a value from another record. You can use his example to create a subquery to get the value from the previous record and then just subtract the it from the Data value. However; the first entry in your example implies you want 2 - Null to equal 2. You can get that effect by adding a IIF function. or maybe the Nz function.
 

Users who are viewing this thread

Back
Top Bottom