From: Christoph Haller <ch@rodos.fzk.de>
To: praveen_vejandla@rediffmail.com
Cc: pgsql-sql@postgresql.org
Subject: Re: averaging interval values
Date: Tue, 12 Nov 2002 17:07:41 +0100
Message-ID: <3DD1274C.8F4C0335@rodos.fzk.de> (raw)
>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ch@rodos.fzk.de, praveen_vejandla@rediffmail.com
Subject: Re: averaging interval values
In-Reply-To: <3DD1274C.8F4C0335@rodos.fzk.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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