pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hannu Krosing <hannu@trust.ee>
To: Billy G. Allie <Bill.Allie@mug.org>
Cc: rodneyr@embratel.com.br
Cc: pgsql-interfaces@hub.org
Cc: bga@mug.org
Subject: Re: [INTERFACES] AVG function
Date: Sat, 28 Aug 1999 23:54:02 +0300
Message-ID: <37C84C6A.39D46C83@trust.ee> (raw)
References: <199908281816.OAA19438@bajor.mug.org>

"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



view thread (4+ messages)

Message-ID: <37C84C6A.39D46C83@trust.ee>
Permalink:  ../37C84C6A.39D46C83@trust.ee/
Also on:    postgresql.org/message-id/37C84C6A.39D46C83@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, Bill.Allie@mug.org, rodneyr@embratel.com.br, pgsql-interfaces@hub.org, bga@mug.org
  Subject: Re: [INTERFACES] AVG function
  In-Reply-To: <37C84C6A.39D46C83@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