Hello the list,
For some time now, I'm struggling with a problem of self join of a table:
I have a usage recording table: CREATE TABLE readings(tm timestamp,
bytesin int, bytesout int);
The readouts are made "occasionally" - the timespan between the readouts
are not very precise, but there is a lot of those readouts.
I need to make a self join of that table to analyze the bandwidth usage
e.g.: when presenting data, for every readout I need to compute the
difference between it and the one immediately preceding it, and divide
that by respective measurement interval.
Initially I've put an additional column with a serial into the readouts
table, and did a join on (p.serial = n.serial+1); but that had an
occasional glitch, when serial actually skipped a value. So I'm trying
to work out a more resiliant/general solution. So far to no avail.
Is there an "sql-idiom" (receipt?) to do such join? the better if
without the spurious seiral column.
Thenx
-R