title: How to truncate last two letters in a string and convert to number in Oracle?
body: <p>I have an Oracle table that shows a column 'Received Quantity' as a string. How do I remove the last two letters in that string and convert the rest to a number?</p>
  
  <pre><code>Select receipt_number
        ,item_name
        ,received_quantity
  from item_table
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>+-----------+----------+-------+
  |    Rcpt 01|Kool GLue |234CS  |
  +-----------+----------+-------+
  |    Rcpt 02|Red GLue  |10CS   |
  +-----------+----------+-------+
  |    Rcpt 03|Bad GLue  |1000CS |
  +-----------+----------+-------+
  </code></pre>
  
  <p>I need help with code to remove the 'CS' in the field and convert the numbers to a number and then calculate the sum of all those numbers.</p>
  
  <p>Eventually, I want to Calculate the Sum of number of Cases for all those items.</p>
  
  <p>The code I'm trying is:</p>
  
  <pre><code>Select receipt_number
        ,item_name
        ,SUM (to_number(cast(received_quantity, -2)))
  from item_table
  group by receipt_number, item_name
  </code></pre>