From: | Michael Blakeley <mike(at)blakeley(dot)com> |
---|---|
To: | pgsql-general(at)postgreSQL(dot)org |
Subject: | interval questions |
Date: | 2000-06-02 00:44:03 |
Message-ID: | p04320421b55cb1ee3b65@blakeley.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I hope someone on the list can suggest a solution for me - given a table like
CREATE TABLE EVENTS( stamp date, id varchar(16), event varchar(128) );
I'm trying to find the average age of the records. I've gotten as far as:
SELECT DISTINCT ON(id) age(stamp) FROM EVENTS;
Now, I need the DISTINCT ON(id), but that means I can't simply avg() the age:
ERROR: Attribute events.id must be GROUPed or used in an
aggregate function
Can anyone suggest a solution? I could do the averaging myself,
except that the output is non-trivial to parse:
7 mons 6 10:29
2 mons 30 07:43:38
3 mons 4 09:50:56
(To be accurate, my code has to get the days in each month right,
etc., and it feels like I'm reinventing the wheel there.)
Thanks in advance for any suggestions.
-- Mike
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Chmara | 2000-06-02 01:21:51 | Re: PostgreSQL article in LinuxWorld |
Previous Message | Joseph Shraibman | 2000-06-02 00:40:02 | make install for docs in 7.0.1 won't work. |