Received: from kodu.home.ee (isdn-54.uninet.ee [194.204.0.118]) by hub.org (8.9.3/8.9.3) with ESMTP id QAA11730 for ; Sat, 28 Aug 1999 16:54:49 -0400 (EDT) (envelope-from hannu@trust.ee) Received: from trust.ee (hannu@localhost [127.0.0.1]) by kodu.home.ee (8.8.7/8.8.7) with ESMTP id XAA00521; Sat, 28 Aug 1999 23:54:03 +0300 Sender: hannu@kodu.home.ee Message-ID: <37C84C6A.39D46C83@trust.ee> Date: Sat, 28 Aug 1999 23:54:02 +0300 From: Hannu Krosing Organization: Trust-O-Matic =?iso-8859-1?Q?O=DC?= X-Mailer: Mozilla 4.5 [en] (X11; U; Linux 2.2.6 i686) X-Accept-Language: en MIME-Version: 1.0 To: "Billy G. Allie" CC: rodneyr@embratel.com.br, pgsql-interfaces@hub.org, bga@mug.org Subject: Re: [INTERFACES] AVG function References: <199908281816.OAA19438@bajor.mug.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit "Billy G. Allie" wrote: > > Hannu Krosing wrote: > > rodneyr@embratel.com.br wrote: > > > > > 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 avg(i * 1.0) from t; > > avg > > --- > > 3.8 > > (1 row) > > > Actually, this will work without the need for a multiplication: > > bga=> select AVG(i::float) from t; > avg > --- > 3.5 > (1 row) The ANSI-fied form of which is : hannu=> select avg(cast(i as float)) from t; avg --- 3.8 (1 row) --------------- Hannu