title: Postgres SQL state: 22P02
body: <p>I need to run the following query in Postgres:</p>
  
  <pre><code>select left(file_date, 10) as date, lob_name, devicesegment, sum(conversion_units::numeric) as units
  from bac_search.dash_search_data
  where (lob_name= 'Mortgage' and file_date::date between (CURRENT_DATE - INTERVAL '30 days') and CURRENT_DATE)
        or (lob_name= 'Loans' and file_date::date between (CURRENT_DATE - INTERVAL '30 days') and CURRENT_DATE)
  group by file_date, lob_name, devicesegment
  order by file_date, lob_name, devicesegment;
  </code></pre>
  
  <p>Despite setting conversion_units to numeric, it is giving me the following error:</p>
  
  <blockquote>
  <pre><code>ERROR:  invalid input syntax for type numeric: ""
  ********** Error **********
  
  ERROR: invalid input syntax for type numeric: ""
  SQL state: 22P02
  </code></pre>
  </blockquote>
  
  <p>Of note, I've done some unit testing and when I run this query for Mortgage and delete the line for Loans, it works fine.  I've isolated the problem to <code>conversion_units::numeric</code> for <code>Loans</code>. Besides the usual conversion (as I've specified here), I'm not sure what else to try. I read through the questions with this error, but they don't seem to mirror my problem. Any help is appreciated! Thanks!</p>