HELP! PL\SQL experts unite! Or I'll get fired!

From: Mark Seto <markseto_at_v-wave.com>
Date: 1997/12/09
Message-ID: <348E41D5.A65EEEB5_at_v-wave.com>#1/1


ok, getting fired is an exageration, but I could use help with the following problem:

Assume a table which contains raw data from a source system. This table contains service calls of machines that contain meter readings. fields in this table:
- Call # (PK)

I need to report the change in meter reading from the previous cal of the machinel. The problem is I cannot reference the last call properly (the machine may have had many calls, I want to reference against the previous call only). The number I am in need of should be calculated from the meter reading of call date of interest - the meter reading of most recent previous call of the call date of interest. My boss says I should create a new field of this data that represents the meter change. Any ideas?

example of data:

call# Serial# meterreading date tech metrchange<-what I need!
01 M01 1000 01/10/97 T01 1000

02        M01        1500            02/12/97        T04            500
03        M04        2000            02/14/97        T06            2000

04        M01        2100            03/04/97        T01            600
05        M04        4000            03/26/97        T04            2000
Received on Tue Dec 09 1997 - 00:00:00 CET

Original text of this message