Trying to sum values from Query JSON with SQL query

I’m trying to sum the values returned from a Query JSON with SQL query, but getting only zero as the result. Here’s my code:
select sum(availableRenewal) from {{query_AllOpptys.data.map(i => parseInt(i.availableRenewal))}}

In the watcher I can see that the JSON object is populated with the right data in the right type (ints not strings). Any ideas? Thanks.

Hey @sfbrophy, good to hear from you again :slight_smile:

We should be able to get this figured out. Can you send over a screenshot of the values of the relevant properties in the property inspector?

We were able to get this sorted out by moving the data type conversion around:

select SUM(CAST(availableRenewal AS NUMBER)) 
from {{ query_AllOpptys.data }}