From: | "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com> |
---|---|
To: | arief# <arief_m_utama(at)telkomsel(dot)co(dot)id> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: sum of a time column |
Date: | 2004-03-05 18:35:24 |
Message-ID: | Pine.LNX.4.33.0403051134070.16900-100000@css120.ihs.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 5 Mar 2004, arief# wrote:
> Dear all,
>
>
> I'm sorry if this sounds stupid or have been talked about before.
>
> Suppose I have a field in my table that's called duration with type
> 'time without timezone'. How do I do sum on this field based on another
> field let say called dateofevent?
>
> SQL: SELECT SUM(duration) FROM durtable GROUP BY dateofevent;
>
> gives me:
>
> ERROR: Unable to select an aggregate function sum(time without time
> zone)
>
> Is this because of me still using PostgreSQL version 7.2.1 from Debian
> Woody? Or some other stupidity?
No, there's just no logical way to add dates. If you want to find the
total number of days those dates are after a certain date, you could do
something like:
select sum('2005-01-01 00:00:00'-dt) from table;
From | Date | Subject | |
---|---|---|---|
Next Message | Paul Thomas | 2004-03-05 18:52:23 | Re: Setting up Postgresql on Linux |
Previous Message | Jim Wilson | 2004-03-05 18:08:33 | Re: relocatable binary distribution |