Re: obtain the difference between successive rows - Mailing list pgsql-general

From Chris Angelico
Subject Re: obtain the difference between successive rows
Date
Msg-id CAPTjJmpJ8JgJFLyipUU5vRF_qbH+f__R0g9js08+j9QSNx2tVA@mail.gmail.com
Whole thread Raw
In response to Re: obtain the difference between successive rows  (Berend Tober <btober@broadstripe.net>)
Responses Re: obtain the difference between successive rows  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Sun, Oct 21, 2012 at 2:30 AM, Berend Tober <btober@broadstripe.net> wrote:
> What about if there is more than one column you want the difference for (...
> coincidentally I am writing a article on this topic right now! ...), say a
> table which is used to record a metered quantity at not-quite regular
> intervals:
> ...
>
> I am working on a write-up of a neat solution using CTE's, but would be
> interested in other's views.

To be quite honest, I would simply read the table directly and then do
the processing in an application language :) But two window functions
should do the trick. Whether or not it's actually more efficient that
way is another question.

ChrisA


pgsql-general by date:

Previous
From: Berend Tober
Date:
Subject: Re: obtain the difference between successive rows
Next
From: Thalis Kalfigkopoulos
Date:
Subject: Re: obtain the difference between successive rows