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 BDB2D5581F for ; Mon, 21 Mar 2005 09:55:09 +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 25310-02 for ; Mon, 21 Mar 2005 09:55:01 +0000 (GMT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by svr1.postgresql.org (Postfix) with SMTP id 7FB9C56400 for ; Mon, 21 Mar 2005 09:54:58 +0000 (GMT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Mon Mar 21 10:54:47 2005 +0100 Received: from rodos.fzk.de (resy6.fzk.de [141.52.68.10]) by resy5.fzk.de (8.12.7/8.12.7/SuSE Linux 0.6) with ESMTP id j2L9shsG004971; Mon, 21 Mar 2005 10:54:46 +0100 Message-ID: <423E99E2.7D428966@rodos.fzk.de> Date: Mon, 21 Mar 2005 10:54:43 +0100 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: Octavio Alvarez Cc: pgsql-sql@postgresql.org Subject: Re: References: Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS - amavis-milter (http://www.amavis.org/) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.022 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/279 X-Sequence-Number: 20758 Octavio Alvarez wrote: > > Sorry, I tried to make my subject as good as possible. Ahem, what subject? > > 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. I cannot see how this could be achieved without the use of a function. But if there is a way after all, I would be interested in learning it. > > Any help will be appreciated. > > --Octavio > -- Regards, Christoph