function ave(integer) does not exist

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

function ave(integer) does not exist

Benedict Holland
Hi All,

This one is confusing. The only difference in my db is that it comes from a user specific template not pg_default.

I run this:




***********************************************************************************************************************************************************
create temp table test (var int);
insert into test (var) values
(1), (2), (3), (4), (5), (6), (243);

select ave(var)
from test;
***********************************************************************************************************************************************************


and I get this as the error:

***********************************************************************************************************************************************************
ERROR:  function ave(integer) does not exist
LINE 1: select ave(var)
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.


********** Error **********

ERROR: function ave(integer) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 8
***********************************************************************************************************************************************************


So why is this happening? I can run a "select sum(var)" and it works.

Thanks,
~Ben
Reply | Threaded
Open this post in threaded view
|

Re: function ave(integer) does not exist

hubert depesz lubaczewski-2
On Tue, Jul 03, 2012 at 02:07:54PM -0400, Benedict Holland wrote:
> This one is confusing. The only difference in my db is that it comes from a
> user specific template not pg_default.

"difference"? between what and what?

> select ave(var)
> from test;
> ***********************************************************************************************************************************************************
>
>
> and I get this as the error:
>
> ***********************************************************************************************************************************************************
> ERROR:  function ave(integer) does not exist
> LINE 1: select ave(var)
>                ^

Never heard of ave() function. What should it do?

> So why is this happening? I can run a "select sum(var)" and it works.

Well, sum() works, because such function (aggregate actually) exists.

Hmm .. perhaps you're looking for avg() - to get average value?

Best regards,

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/

--
Sent via pgsql-general mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Reply | Threaded
Open this post in threaded view
|

Re: function ave(integer) does not exist

Benedict Holland
Oh heck. Yes, I misread avg(expression as ave. Sorry for this.

~ben

On Tue, Jul 3, 2012 at 2:13 PM, hubert depesz lubaczewski <[hidden email]> wrote:
On Tue, Jul 03, 2012 at 02:07:54PM -0400, Benedict Holland wrote:
> This one is confusing. The only difference in my db is that it comes from a
> user specific template not pg_default.

"difference"? between what and what?

> select ave(var)
> from test;
> ***********************************************************************************************************************************************************
>
>
> and I get this as the error:
>
> ***********************************************************************************************************************************************************
> ERROR:  function ave(integer) does not exist
> LINE 1: select ave(var)
>                ^

Never heard of ave() function. What should it do?

> So why is this happening? I can run a "select sum(var)" and it works.

Well, sum() works, because such function (aggregate actually) exists.

Hmm .. perhaps you're looking for avg() - to get average value?

Best regards,

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/