| From: | Christoph Haller <ch(at)rodos(dot)fzk(dot)de> |
|---|---|
| To: | praveen_vejandla(at)rediffmail(dot)com |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: averaging interval values |
| Date: | 2002-11-12 16:07:41 |
| Message-ID: | 3DD1274C.8F4C0335@rodos.fzk.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Stephan Szabo | 2002-11-12 16:30:30 | Re: Efficient ON DELETE trigger when referential integrity is |
| Previous Message | praveen vejandla | 2002-11-12 15:40:07 | averaging interval values |