Received: from bajor.mug.org (wormhole.mug.org [207.158.132.1]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA91300 for ; Sat, 28 Aug 1999 14:12:12 -0400 (EDT) (envelope-from bga@bajor.mug.org) Received: from bajor.mug.org (localhost [127.0.0.1]) by bajor.mug.org (8.8.7/UW7.0.1) with ESMTP id OAA19438; Sat, 28 Aug 1999 14:16:17 -0400 (EDT) Message-Id: <199908281816.OAA19438@bajor.mug.org> X-Mailer: exmh version 2.0.2 2/24/98 From: "Billy G. Allie" Reply-To: "Billy G. Allie" To: Hannu Krosing Cc: rodneyr@embratel.com.br, pgsql-interfaces@hub.org, bga@mug.org Subject: Re: [INTERFACES] AVG function In-Reply-To: Your message of "Sat, 28 Aug 1999 18:48:35 +0300." <37C804D3.BB1B63AA@trust.ee> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==_Exmh_1010494560P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit Date: Sat, 28 Aug 1999 14:16:16 -0400 Sender: bga@mug.org --==_Exmh_1010494560P Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hannu Krosing wrote: > 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) > Actually, this will work without the need for a multiplication: bga=> select * from t; i - 1 2 3 4 5 6 (6 rows) bga=> select AVG(i::float) from t; avg --- 3.5 (1 row) -- ____ | Billy G. Allie | Domain....: Bill.Allie@mug.org | /| | 7436 Hartwell | Compuserve: 76337,2061 |-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie@email.msn.com |/ |LLIE | (313) 582-1540 | --==_Exmh_1010494560P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 5.0i for non-commercial use MessageID: 2LrPfS2IDEc5pYymmWNDQTaLu/mEy4Ev iQA/AwUBN8gncKFebSRz8o+3EQIfwwCbBJ72/k81TymvihWdTJkoEZcAo2sAn3fx WsD0kWa5mOaSNNQ3bUCn5D3V =gVag -----END PGP SIGNATURE----- --==_Exmh_1010494560P--