In postgres DB, I have a jsonb column which has a data in string array, like:
{
"name": "john doe",
"testData": "["1", "2", "3", "", "", ""]"
}
I want to convert string testData to array and then those string integers to int and then sum them up.
select sum(ARRAY(test_column->>'testData')::int) as sum from table;
Output -> "6"