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

Re: [INTERFACES] AVG function

From: Hannu Krosing <hannu(at)trust(dot)ee>
To: "Billy G(dot) Allie" <Bill(dot)Allie(at)mug(dot)org>
Cc: rodneyr(at)embratel(dot)com(dot)br, pgsql-interfaces(at)hub(dot)org, bga(at)mug(dot)org
Subject: Re: [INTERFACES] AVG function
Date: 1999-08-28 20:54:02
Message-ID: 37C84C6A.39D46C83@trust.ee (view raw or flat)
Thread:
Lists: pgsql-interfaces
"Billy G. Allie" wrote:
> 
> Hannu Krosing wrote:
> > rodneyr(at)embratel(dot)com(dot)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

In response to

pgsql-interfaces by date

Next:From: martenDate: 1999-08-29 05:50:23
Subject: ODBC-Interfaces - connection options ? Error !
Previous:From: Billy G. AllieDate: 1999-08-28 18:16:16
Subject: Re: [INTERFACES] AVG function

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