title: Using COALESCE to handle NULL values in PostgreSQL
body: <p>I have the following query </p>
  
  <pre><code>SELECT  DISTINCT 
       pt.incentive_marketing, 
       pt.incentive_channel, 
       pt.incentive_advertising 
  FROM test.pricing pt 
  WHERE pt.contract_id = 90000 
  group by 1,2,3 
  order by pt.incentive_marketing;
  </code></pre>
  
  <p>The above query returns the o/p as shown in the attached image
  <img src="https://i.stack.imgur.com/1mabt.jpg" alt="enter image description here"></p>
  
  <p><strong>However I want to replace all null values by 0 using COALESCE</strong>
  Please let me know how this can be achieved in above SELECT query</p>
  
  <p>Now I further modified the query using coalesce as below</p>
  
  <pre><code>SELECT  
       COALESCE( pt.incentive_marketing, '0' ), 
       COALESCE(pt.incentive_channel,'0'), 
       COALESCE( pt.incentive_advertising,'0') 
  FROM test.pricing pt 
  WHERE pt.contract_id = 90000 
  group by 1,2,3 
  </code></pre>
  
  <p>the result of which is as attached in image 2.</p>
  
  <p>I still receive one row with blank values</p>
  
  <p><img src="https://i.stack.imgur.com/6PZAw.jpg" alt=""></p>