I am going to calculate the sum of values in specific column. this is my code:
SELECT sum(A.number_Of_Households)
FROM (SELECT
json_data->'benefits' ->> 'numberOfHouseholds' as number_Of_Households
FROM ccbc_public.application a
inner join ccbc_public.application_form_data afd on a.id = afd.application_id
inner join ccbc_public.form_data f on f.id = afd.form_data_id
where ccbc_public.application_status(a) <> 'draft') As A
When I run the code, I got this error:
ERROR: function sum(text) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts.