pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hannu Krosing <hannu@trust.ee>
To: rodneyr@embratel.com.br
Cc: pgsql-interfaces@hub.org
Subject: Re: [INTERFACES] AVG function
Date: Sat, 28 Aug 1999 18:48:35 +0300
Message-ID: <37C804D3.BB1B63AA@trust.ee> (raw)
References: <032567DB.00534444.00@ntrjo008.nt.embratel.com.br>

rodneyr@embratel.com.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



view thread (4+ messages)  latest in thread

Message-ID: <37C804D3.BB1B63AA@trust.ee>
Permalink:  ../37C804D3.BB1B63AA@trust.ee/
Also on:    postgresql.org/message-id/37C804D3.BB1B63AA@trust.ee

 · 

reply

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-interfaces@postgresql.org
  Cc: hannu@trust.ee, rodneyr@embratel.com.br, pgsql-interfaces@hub.org
  Subject: Re: [INTERFACES] AVG function
  In-Reply-To: <37C804D3.BB1B63AA@trust.ee>

* 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