title: Getting Error - ORA-01858: a non-numeric character was found where a numeric was expected
body: <p>I am getting the error in the below sql:</p>
  
  <blockquote>
    <p>ORA-01858: a non-numeric character was found where a numeric was expected</p>
  </blockquote>
  
  <pre><code>SELECT   c.contract_num,
           CASE
              WHEN   (  MAX (TO_CHAR (TO_DATE (c.event_dt, 'YYYY-MM-DD'), 'MMDD'))
                      - MIN (TO_CHAR (TO_DATE (c.event_dt, 'YYYY-MM-DD'), 'MMDD')))
                   / COUNT (c.event_occurrence) &lt; 32
              THEN
                'Monthly'
              WHEN       (  MAX (
                              TO_CHAR (TO_DATE (c.event_dt, 'YYYY-MM-DD'), 'MMDD'))
                          - MIN (
                              TO_CHAR (TO_DATE (c.event_dt, 'YYYY-MM-DD'), 'MMDD')))
                       / COUNT (c.event_occurrence) &gt;= 32
                   AND   (  MAX (
                              TO_CHAR (TO_DATE (c.event_dt, 'YYYY-MM-DD'), 'MMDD'))
                          - MIN (
                              TO_CHAR (TO_DATE (c.event_dt, 'YYYY-MM-DD'), 'MMDD')))
                       / COUNT (c.event_occurrence) &lt; 91
              THEN
                'Quarterley'
              ELSE
                'Yearly'
           END
  FROM     ps_ca_bp_events c
  GROUP BY c.contract_num;
  </code></pre>