title: PGSQL - No function matches the given name and argument types. You might need to add explicit type casts
body: <p>This code gives an error. I have looked similar type questions and couldn't find the answer.</p>
  
  <p><code>sum(COALESCE(((rpt.report_target_data::json-&gt;&gt;'itemQuantity')::int)::int),0) as itemQuantity,</code></p>
  
  <p><strong>report_target_data</strong> is a json object and 'itemQuantity' is an element of that json. Sometimes that field contains an empty value. So when I try to get the sum it gives an error because postgres cannot get the sum if a column had a empty value. What is the wrong with the above code. It there a way to walk around that matter? Is there a way to calculate sum even if some rows contain empty values?</p>
  
  <p>Here is the error of the above code -> </p>
  
  <blockquote>
    <p>No function matches the given name and argument types. You might need to add explicit type casts.</p>
  </blockquote>