Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula using previous record.

Status
Not open for further replies.

n4467r

Technical User
Oct 10, 2002
9
US
I am new to this board and have a question.

I have a database set to log hours of use based on an hour meter. To calculate current record usage I would subtract the previous record meter reading from the current record meter reading. Entering a beginning meter reading would seem redundant but I have not been able to come up with a formula to satisfy this situation.

The result would be shown as usage on a report.

Thanks for the help.

David
 
using a sub query with an alias should do it assuming you have a read date as well

SELECT table1.reading - (select a.reading from table1 as a where a.hour - table1.hour -1 and a.readdate = table1.readdate)
from table1

may have to use dateadd to get you hours but the above shold be along the lines you want
 
Thanks for the reply. Being a bit new to this stuff I am not sure I completely understand the syntax but if I play with it for a while I may just get it!

Thanks again....

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top