title: PostgreSql Queries treats Int as string datatypes
body: <p>I store the following rows in my table ('DataScreen') under a JSONB column ('Results')</p>
  
  <pre><code>{"Id":11,"Product":"Google Chrome","Handle":3091,"Description":"Google Chrome"}
  {"Id":111,"Product":"Microsoft Sql","Handle":3092,"Description":"Microsoft Sql"}
  {"Id":22,"Product":"Microsoft OneNote","Handle":3093,"Description":"Microsoft OneNote"}
  {"Id":222,"Product":"Microsoft OneDrive","Handle":3094,"Description":"Microsoft OneDrive"}
  </code></pre>
  
  <p>Here, In this JSON objects "Id" amd "Handle" are integer properties and other being string properties.</p>
  
  <p>When I query my table like below</p>
  
  <pre><code>Select Results-&gt;&gt;'Id'  From DataScreen  
  order by Results-&gt;&gt;'Id' ASC
  </code></pre>
  
  <p>I get the improper results because PostgreSql treats everything as a text column and hence does the ordering according to the text, and not as integer.
  Hence it gives the result as </p>
  
  <pre><code>11,111,22,222 
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>11,22,111,222.
  </code></pre>
  
  <p>I don't want to use explicit casting to retrieve like below</p>
  
  <pre><code>Select Results-&gt;&gt;'Id'  From DataScreen order by CAST(Results-&gt;&gt;'Id' AS INT)  ASC
  </code></pre>
  
  <p>because I will not be sure of the datatype of the column due to the fact that JSON structure will be dynamic and the keys and values may change next time. and Hence could happen the same with another JSON that has Integer and string keys.</p>
  
  <p>I want something so that Integers in Json structure of JSONB column are treated as integers only and not as texts (string).</p>
  
  <p>How do I write my query so that Id And Handle are retrieved as Integer Values and not as strings , without explicit casting?</p>