Postgres aggregates like SUM(foo) return a string, even if foo is an integer.
How do I cast the sum to an integer so the resulting array of relations contains an integer not a string?
I tried to cast it using ::integer
Widget.select("SUM(points) as totalpoints::integer, agent, company")
but postgres throws error PG::Error: ERROR: syntax error at or near "::"
It seems there should be some way to tell rails - short of iterating through each returned array element - that the SUM of an INT is an INT?