Re: sum of a time column

From: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
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 09:26:24
Message-ID: Pine.LNX.4.44.0403051024420.16139-100000@kix.fsv.cvut.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

you can sum only interval type

create type x (a inteval);

testdb011=> insert into x values ('1 day'::interval);
INSERT 18871 1
testdb011=> insert into x values ('1 day'::interval);
INSERT 18872 1
testdb011=> insert into x values ('1 day'::interval);
INSERT 18873 1
testdb011=> insert into x values ('1 day'::interval);
INSERT 18874 1
testdb011=> insert into x values ('1 day'::interval);
INSERT 18875 1
testdb011=> insert into x values ('1 day'::interval);
testdb011=> select sum(i) from x;
sum
--------
6 days

regards
Pavel Stehule

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?
>
>
> TIA, Regards.
> -arief
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message arief# 2004-03-05 09:27:57 sum of a time column
Previous Message Mike Mascari 2004-03-05 09:04:37 Re: Moving from MySQL to PGSQL....some questions (multilevel