From: | Béatrice Yueksel <beatrice(dot)yueksel(at)it-raum(dot)ch> |
---|---|
To: | Christoph Haller <ch(at)rodos(dot)fzk(dot)de> |
Cc: | Octavio Alvarez <alvarezp(at)tecbc(dot)mx>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Your question about date |
Date: | 2005-03-21 10:59:18 |
Message-ID: | 1111402758.5174.22.camel@nimas.it-raum.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Dear Christoph,
perhaps you could try something like this example.
Regards,
Béatrice
The table:
----------
# select * from test;
date
------------
2005-02-02
2005-03-05
2005-04-07
2005-05-02
(4 rows)
The query
----------
SELECT
(( select test1.date
from test test1
where test1.date > test.date limit 1)
- test.date ) AS result from test;
t1.date >
RESULT:
-------
result
--------
31
33
25
Am Montag, den 21.03.2005, 10:54 +0100 schrieb Christoph Haller:
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
--
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2005-03-21 11:35:41 | Re: index scan |
Previous Message | Mihail Nasedkin | 2005-03-21 10:05:15 | Re: index scan |