erusev
1
I have a query that looks like this:
SELECT SUM(count) as rq
FROM usage_ip ...
The data it returns looks like this:
![CleanShot 2023-03-11 at 17.26.52@2x](https://community.retool.com/uploads/default/original/2X/f/fe8d2bd9f17fcc8cd1dd8c31f1a08be97b799ffc.jpeg)
Why are integers strings? I can't do _.sum()
on them, for example.
When I run the same query in the database (outside of Retool), these are integer values.
Hey @erusev, welcome to the community ![:hugs: :hugs:](http://community.retool.com/images/emoji/apple/hugs.png?v=12)
Seems like you have mixed data types for that column. If the input values are of a mixed data type, the result will be of the higher data type.
But you can cast to INT for _.sum()
to work
SELECT
CAST(SUM(count) AS INTEGER) AS rq
FROM
usage_ip
![:v: :v:](http://community.retool.com/images/emoji/apple/v.png?v=12)
2 Likes
erusev
3
Nice! It works when I cast to INT ![:star_struck: :star_struck:](http://community.retool.com/images/emoji/apple/star_struck.png?v=12)
I don't get it though -- that column is an integer (int2
), and all values in it are integers -- where are the mixed data types coming from ![:thinking: :thinking:](http://community.retool.com/images/emoji/apple/thinking.png?v=12)