Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 476E39F9B05 for ; Fri, 15 Dec 2006 09:12:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 01887-09 for ; Fri, 15 Dec 2006 09:12:02 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web31806.mail.mud.yahoo.com (web31806.mail.mud.yahoo.com [68.142.207.69]) by postgresql.org (Postfix) with SMTP id EFAC09FA1FD for ; Fri, 15 Dec 2006 09:12:02 -0400 (AST) Received: (qmail 5248 invoked by uid 60001); 15 Dec 2006 13:12:01 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=joaOfGJULEgsRZ4BtOEixEq6B0BkAbkznmHu5XbFnzVtYeNvoUNvRNLrh3jchX0AucsOcQMQ6GKKPuytili9r5HwkAl0FL7R3NS6eym9LoEFDniwrsh5abwJnS4itJ8s6F3QvjWt5zvb4L1pNBbCTAslohvc4gxWyJLg4Jq5H/o=; X-YMail-OSG: h9I1jsAVM1n3ThxOe3TCAVp6AESEItrL7Wao9_RQiHOVJav.D89RGKmvXrsK_VyLlmUo9Zfdd6D3sE.ArxJfMvheasPm6LQiZsVNCxEBjaqVksfq6cbRtnplfU4Iqdk5oZmzxWJRHjJtZQ-- Received: from [75.84.83.178] by web31806.mail.mud.yahoo.com via HTTP; Fri, 15 Dec 2006 05:12:01 PST Date: Fri, 15 Dec 2006 05:12:01 -0800 (PST) From: Richard Broersma Jr Subject: Re: Need to subtract values between previous and current row To: Partha Guha Roy , pgsql-sql@postgresql.org In-Reply-To: <6bdfe880612150427o19bfe90ch87a972c0f5898ffb@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <297264.3730.qm@web31806.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/113 X-Sequence-Number: 27069 > > ID ATIME (MM/dd/yyyy) > == ==== > 1 10/12/2006 > 2 10/14/2006 > 3 10/18/2006 > 4 10/22/2006 > 5 10/30/2006 > > Now I need a query that will subtract atime of row 1 from row 2, row2 from > row3 and so on... just an idea. select (A.atime - max(B.atime)) duration from table A join table B on (A.atime > B.atime) group by A.atime; Regards, Richard Broersma Jr.