compare field values

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
 
D

Duane Hookom

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;
 

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