Re: obtain the difference between successive rows

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: ochaussavoine <olivier(dot)chaussavoine(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: obtain the difference between successive rows
Date: 2012-10-20 11:02:17
Message-ID: 508284B9.9020501@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 20/10/2012 11:54, ochaussavoine wrote:
> Hi,
> I have a table 'tmvt' with a field 'created' in the row, and would like to
> compute the difference between successive rows. The solution I found is:
>
> It is complicate and very long to perform. The problem could be simply
> solved with MySql by creating a new field and updating it using a statement
> with @.
> I beleive this is a common problem for users. Do you know a simpler solution
> with postgreSql?

I think you can do it with a window function.

http://www.postgresql.org/docs/9.2/static/tutorial-window.html
http://www.postgresql.org/docs/9.2/static/functions-window.html

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thalis Kalfigkopoulos 2012-10-20 13:06:27 Re: obtain the difference between successive rows
Previous Message ochaussavoine 2012-10-20 10:54:22 obtain the difference between successive rows