X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5E425565E3 for ; Fri, 18 Mar 2005 17:56:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 28896-04 for ; Fri, 18 Mar 2005 17:55:58 +0000 (GMT) Received: from guardian.tecbc.mx (guardian.tecbc.mx [201.140.139.2]) by svr1.postgresql.org (Postfix) with ESMTP id 74662560EE for ; Fri, 18 Mar 2005 17:55:56 +0000 (GMT) Received: from octavio.tecbc.mx (octavio.tecbc.mx [201.140.139.18]) (authenticated bits=0) by guardian.tecbc.mx (8.13.1/8.13.1) with ESMTP id j2IHq6tZ030616 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) for ; Fri, 18 Mar 2005 09:52:06 -0800 To: pgsql-sql@postgresql.org Date: Fri, 18 Mar 2005 09:57:25 -0800 From: "Octavio Alvarez" Organization: TBC Universidad Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: User-Agent: Opera M2/7.54 (Win32, build 3929) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.57 tagged_above=0 required=5 tests=MISSING_SUBJECT X-Spam-Level: * X-Archive-Number: 200503/267 X-Sequence-Number: 20746 Sorry, I tried to make my subject as good as possible. I have a table where I store the dates in which I take out of my inventory (like "installation dates") table --------------- row_id SERIAL date DATE fk_item INTEGER and that's pretty much it. I want to have a query returning how long have been certain items lasting. Say I have: SELCT date FROM table WHERE fk_item = "INKJET_INK-BW" date ------------- 2005-02-02 2005-03-05 2005-04-07 2005-05-02 I need something to calculate the intervals between those dates, like this: intervals (in days) -------------------- 31 34 25 So I can get the stddev and stuff from the "duration" of the items. I've been having a hard time with it. I'm trying NOT to program new functions. Any help will be appreciated. --Octavio -- Ing. Octavio Alvarez Piza, Jefe de Informática, TBC Universidad. Tel.: +52 (664) 621-7111 ext. 133; E-mail: alvarezp@tecbc.net