Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-interfaces by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group