pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedaveraging interval values
2+ messages / 2 participants
[nested] [flat]
* averaging interval values
@ 2002-11-12 15:40 praveen vejandla <praveen_vejandla@rediffmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: praveen vejandla @ 2002-11-12 15:40 UTC (permalink / raw)
To: pgsql-sql
Hi All,
I have a table with one varchar field that contains time
intervals.
Is there any way to average or sum those intervals in a table ?
Table name : test
field name : t2 (varchar(40))
it contains all intervals as below
t2
1:01:01
0:25:15
7:09:01
8:09:05
Is there any way to average or sum those above values using a
function?
i could not type cast the varchar(40) to interval type.
How to change the datatype of field from varchar to interval?
Thanks and Regards,
Praveen
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: averaging interval values
@ 2002-11-12 16:07 Christoph Haller <ch@rodos.fzk.de>
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Haller @ 2002-11-12 16:07 UTC (permalink / raw)
To: praveen_vejandla@rediffmail.com; +Cc: pgsql-sql
>
> 1:01:01
> 0:25:15
> 7:09:01
> 8:09:05
>
> Is there any way to average or sum those above values using a
> function?
>
> i could not type cast the varchar(40) to interval type.
>
> How to change the datatype of field from varchar to interval?
>
Try
SELECT CAST(CAST (t2 AS TEXT) AS INTERVAL) FROM test;
SELECT AVG(CAST(CAST (t2 AS TEXT) AS INTERVAL)) FROM test;
SELECT SUM(CAST(CAST (t2 AS TEXT) AS INTERVAL)) FROM test;
It works fine on my machine, I'm using PostgreSQL 7.2.1.
Regards, Christoph
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-11-12 16:07 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-12 15:40 averaging interval values praveen vejandla <praveen_vejandla@rediffmail.com>
2002-11-12 16:07 Re: averaging interval values Christoph Haller <ch@rodos.fzk.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox