Re: [INTERFACES] AVG function - Mailing list pgsql-interfaces

From Hannu Krosing
Subject Re: [INTERFACES] AVG function
Date
Msg-id 37C84C6A.39D46C83@trust.ee
Whole thread Raw
In response to Re: [INTERFACES] AVG function  ("Billy G. Allie" <Bill.Allie@mug.org>)
List pgsql-interfaces
"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


pgsql-interfaces by date:

Previous
From: "Billy G. Allie"
Date:
Subject: Re: [INTERFACES] AVG function
Next
From: marten@feki.toppoint.de
Date:
Subject: ODBC-Interfaces - connection options ? Error !