title: COALESCE types text and integer cannot be matche
body: <p>Basically I have a column item_importance based on it's value I want to return an output <code>zone_index</code></p>
  <pre><code>CASE
              WHEN item_importance in ('kvi', 'super_kvi') 
                  THEN 
                      data-&gt;&gt;'zone_index'
              WHEN item_importance in ('non_kvi_1', 'non_kvi_2') 
                  THEN 
                      data-&gt;&gt;'zone_price_diff_non_kvi'
                      
          END as zone_index
  </code></pre>
  <p>The following query works, but on the output if <code>data-&gt;&gt;'zone_index'</code> or <code>data- &gt;&gt;'zone_price_diff_non_kvi'</code> is null, it returns null. How can I make the default value if null to be 0 for <code>zone_index</code></p>
  <p>I tried <code>COALESCE(data-&gt;&gt;'zone_index', 0)</code></p>
  <p>I get</p>
  <blockquote>
  <p>ERROR:  COALESCE types text and integer cannot be matched
  LINE 9:      COALESCE(data-&gt;&gt;'zone_index', 0)</p>
  </blockquote>