compare field values

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I need to calculate the difference between values from one
record to the next, only if the next value is less then
the previous otherwise it is 0.
i.e.:
TIME EVAP RATE
1300 6.55 0
1310 6.54 0.01
1320 6.54 0
1330 6.50 0.04
1340 6.60 0
 
Try something like:
Select [Time], Evap, Evap-(Select Top 1 Evap From tblA A where
A.[Time]<tblA.[Time] ORDER by [Time] Desc) as Rate
FROM tblA;
 
Back
Top