Search Postgresql Archives

self join for history analyzis

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux