title: How to convert Varchar to Double in sql?
body: <p>I have problem with my query when I was trying to convert the varchar field to double (numeric). I have this sql statement:</p>
  
  <pre><code>SELECT fullName, CAST(totalBal as numeric(9,2) FROM client_info ORDER BY totalBal DESC
  </code></pre>
  
  <p>Actually I want to display the values of <code>totalBal</code> in descending order. But since that field is in varchar, the resultset is sometimes wrong. This is the resultset when I tried to query using this statement:</p>
  
  <pre><code>SELECT fullName, totalBal FROM client_info ORDER BY totalBal DESC 
  </code></pre>
  
  <p>Resultset is:</p>
  
  <p><img src="https://i.stack.imgur.com/omUza.png" alt="enter image description here"></p>
  
  <p>The sorting of <code>totalBal</code> is not correct. So I decided to convert the varchar to numeric so that it might be sorted perfectly. Any idea?</p>