Re: [INTERFACES] AVG function

From: Hannu Krosing <hannu(at)trust(dot)ee>
To: rodneyr(at)embratel(dot)com(dot)br
Cc: pgsql-interfaces(at)hub(dot)org
Subject: Re: [INTERFACES] AVG function
Date: 1999-08-28 15:48:35
Message-ID: 37C804D3.BB1B63AA@trust.ee
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-interfaces

rodneyr(at)embratel(dot)com(dot)br wrote:
>
> I'm using the AVG function to get the average of some integer values of my
> database,
> but the result is comming in the integer format too, and I'm loosing some
> precision.
>
> Does someone know how to get the result of the AVG function in a float type,
> without
> changing the structure of my table?

Try this:

hannu=> select * from t;
i
-
4
4
4
4
3
(5 rows)

hannu=> select avg(i * 1.0) from t;
avg
---
3.8
(1 row)

-------------
Hannu

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Spirou 1999-08-28 16:29:25 [Fwd: bug ? get_groname: group 0 not found]
Previous Message rodneyr 1999-08-28 15:09:39 AVG function