Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id E637D9FA380 for ; Fri, 15 Dec 2006 12:24:13 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 99519-06 for ; Fri, 15 Dec 2006 12:24:02 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web31801.mail.mud.yahoo.com (web31801.mail.mud.yahoo.com [68.142.207.64]) by postgresql.org (Postfix) with SMTP id AD7439FA2A7 for ; Fri, 15 Dec 2006 12:24:02 -0400 (AST) Received: (qmail 92275 invoked by uid 60001); 15 Dec 2006 16:21:09 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=2emrzFCID0zuqDGOYX9lmn0BZP9DCL5ccoFnNpfX6I0JMeR5+5s6KXdO163zOuVyiFfgBmBM70MhIMCI+lCrJ2Wz6xxWWmCpvovPovVOXyIggesvPj5F7IUuD9Wz/cPxwQVF02vBVQgWYzbJxLJxfuvaJAE3kpUmCVnFW+c0UFs=; X-YMail-OSG: YuijQ5AVM1l4ixZ0FnYjU8ErLvVfIPiDmo0dmZ3Uz7EhVcZ8YcycRNSZzlYnoGRogsqe3.Qvw271tCbQUgEeVmeHim5ZUdrnBw3mWYfvOwMeIojrEAhvB12wisi7bTeKc54VjGtixQrSGZEVXf1LagtnwE1w Received: from [12.177.97.50] by web31801.mail.mud.yahoo.com via HTTP; Fri, 15 Dec 2006 08:21:08 PST Date: Fri, 15 Dec 2006 08:21:08 -0800 (PST) From: Richard Broersma Jr Subject: Re: Need to subtract values between previous and current row To: Ragnar Cc: Partha Guha Roy , pgsql-sql@postgresql.org In-Reply-To: <1166198816.6369.179.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <294943.92264.qm@web31801.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/118 X-Sequence-Number: 27074 > not bad, except you miss the initial state for each cid, > and I do not see how you get the final duration. > cid | duration | state > -----+----------+------- > 101 | 2 | 1 > 101 | 2 | 2 > 101 | 3 | 1 > 101 | 3 | 2 > 102 | 2 | 1 > 102 | 2 | 2 > 102 | 2 | 3 > (7 rows) Good catch! I should have read the requirements a little more closely, but at 4:30 am when I just woke up, slight details are very hard for me to focus on. :o) Regards, Richard Broersma Jr.