Re: BUG #11553: Sum function does not exist in Create View - Mailing list pgsql-bugs

From John R Pierce
Subject Re: BUG #11553: Sum function does not exist in Create View
Date
Msg-id 542DD792.8050201@hogranch.com
Whole thread Raw
In response to BUG #11553: Sum function does not exist in Create View  (Harry@HarryClarke.me.uk)
List pgsql-bugs
On 10/2/2014 8:11 AM, Harry@HarryClarke.me.uk wrote:
> The following bug has been logged on the website:
>
> Bug reference:      11553
> Logged by:          Harry Clarke
> Email address:      Harry@HarryClarke.me.uk
> PostgreSQL version: 9.3.5
> Operating system:   Windows 8.1 64bit
> Description:
>
> When attempting to create a view using the following commands
> CREATE VIEW myschema.vc17_tetrad_months AS
>   SELECT mv.tetrad,
>     sum(mv.month) AS months_visited,
>     mv.the_geom
>   FROM ( SELECT
>    ...
>    ) mv
> GROUP BY mv.tetrad, mv.the_geom;;
>
> The error message
> ERROR:  function sum(text) does not exist
> LINE 5:     sum(mv.month) AS months_visited,
>              ^
> HINT:  No function matches the given name and argument types. You might need
> to add explicit type casts.
>
> is returned. However, if the function "sum" is replaced by the function
> "count". No error message is returned, and the expected result is obtained.
>
>

what datatype is mv.month ?

if its TEXT as the error says, well, you can't add strings, can you?
maybe your inner query (which you didn't show) should have returned an
INTEGER instead of text...



--
john r pierce                                      37N 122W
somewhere on the middle of the left coast

pgsql-bugs by date:

Previous
From: Harry@HarryClarke.me.uk
Date:
Subject: BUG #11553: Sum function does not exist in Create View
Next
From: David G Johnston
Date:
Subject: Re: BUG #11477: psql -L no stderr