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 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
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
From | Date | Subject | |
---|---|---|---|
Next Message | marten | 1999-08-29 05:50:23 | ODBC-Interfaces - connection options ? Error ! |
Previous Message | Billy G. Allie | 1999-08-28 18:16:16 | Re: [INTERFACES] AVG function |