title: Select from JSONB field with WHERE clause
body: <p>Just installed 9.4 and trying to use JSONB field type.</p>
  
  <p>I've made a table with jsonb field and able to select from it:</p>
  
  <pre><code>select statistics-&gt;'statistics'-&gt;'all_trades'-&gt;'all'-&gt;'all_trades_perc_profit' as profitable_perc FROM  trade_statistics
  </code></pre>
  
  <p>Works fine.</p>
  
  <p>Now I want to filter results based on field value:</p>
  
  <pre><code>select statistics-&gt;'statistics'-&gt;'all_trades'-&gt;'all'-&gt;'all_trades_perc_profit' as profitable_perc FROM  trade_statistics WHERE profitable_perc &gt; 1
  
  //There is no "profitable_perc" column
  </code></pre>
  
  <p>Does not work. </p>
  
  <p>If I try to convert result to double, does not work either.</p>
  
  <pre><code>select cast(statistics-&gt;'statistics'-&gt;'all_trades'-&gt;'all'-&gt;'all_trades_perc_profit' as double precision) as profitable_perc FROM  trade_statistics
  
  //cant convert jsonb into double precision
  </code></pre>
  
  <p><strong>How should I use select results in WHERE clause in case of jsonb?</strong></p>