PostgreSQL sum typecasting as a bigint when argument types are int
<p>I know someone asked the same question from <a href="https://stackoverflow.com/questions/20203081/postgresql-sum-typecasting-as-a-bigint">PostgreSQL sum typecasting as a bigint</a> a while ago, but I don't see it was answered. I am adding value of a column whose type is integer using sum function, but it will overflow when I adding two 1.5 billion. I want the sum result to be bigint. Is there anyway to achieve it? Thanks in advance. I tried following but didn't work.</p>

<pre><code>sum(count)::bigint AS total
</code></pre>

<p>If I do as following I am still getting error
    sum(count::bigint) AS total</p>

<pre><code>Caused by: org.postgresql.util.PSQLException: ERROR: cannot change data type of column "total" from integer to numeric
</code></pre>