pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Broersma Jr <rabroersma@yahoo.com>
To: Partha Guha Roy <partha.guha.roy@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Need to subtract values between previous and current row
Date: Fri, 15 Dec 2006 06:01:28 -0800 (PST)
Message-ID: <519101.72709.qm@web31802.mail.mud.yahoo.com> (raw)
In-Reply-To: <6bdfe880612150521n137d80f7q463955f26db1cef0@mail.gmail.com>

> CID        ATIME          STATE
> 101        12/10/2006     1
> 101        12/12/2006     2
> 101        12/14/2006     1
> 101        12/17/2006     2
> 102        12/14/2006     1
> 102        12/16/2006     2
> 102        12/18/2006     3

select A.cid, (A.atime - max(B.atime)) duration, A.state
from table A join table B
on (A.atime > B.atime and A.cid = B.cid)
group by A.atime, A.cid, A.state;




view thread (10+ messages)  latest in thread

Message-ID: <519101.72709.qm@web31802.mail.mud.yahoo.com>
Permalink:  ../519101.72709.qm@web31802.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/519101.72709.qm@web31802.mail.mud.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rabroersma@yahoo.com, partha.guha.roy@gmail.com
  Subject: Re: Need to subtract values between previous and current row
  In-Reply-To: <519101.72709.qm@web31802.mail.mud.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox