Query to figure difference in odometers

K

Keith E. Beake

I'm writing a database to track a rather large fleet of
vehicles and service equipment. The top level table
consists of constants; ie. VehicleID, year, make, model,
etc. The next table linked by VehicleID is the workorders
containing pertinent information including dates of
service, received, etc. and the most important is the
odometer reading. This will track hours or mileage
depending on the equipment type. I have a select query
that will take the first two in a descending order (last
time in for service and time prior) and I'm trying to
figure out a way to calculate and analyze the difference
of the two, being compared by a seperate table that will
determine based from VehicleTypeID if it's in or out of
the service window for routine maintanence. Can anyone
advise me on how to effectively do this?

Thanks in advance,
Keith E. Beake
kbeake@cox(remove).(forspam)net
 
J

Jeff Boyce

Keith

It sounds like the structure of your table has a field for [OdometerReading]
and a field for [HoursUsed]. Either way, you would need to subtract the
value in one row from the value in the "next" row to determine the
difference.

While this may be do-able via a query, another approach would be to consider
is building a procedure that retrieves the two rows and calculates the
difference.
 

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