Re: obtain the difference between successive rows

From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: obtain the difference between successive rows
Date: 2012-10-20 15:42:37
Message-ID: CAPTjJmpJ8JgJFLyipUU5vRF_qbH+f__R0g9js08+j9QSNx2tVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Oct 21, 2012 at 2:30 AM, Berend Tober <btober(at)broadstripe(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thalis Kalfigkopoulos 2012-10-20 15:54:11 Re: obtain the difference between successive rows
Previous Message Berend Tober 2012-10-20 15:30:23 Re: obtain the difference between successive rows