title: ERROR: COALESCE types timestamp without time zone and integer cannot be matched (Postgresql)
body: <p><strong>## PROBLEM ##</strong>  </p>
  
  <p>I got error from this script (<strong>Postgresql 9.3.2</strong>)<br>
  ( It's OK in MS SQL Server )</p>
  
  <pre><code>SELECT 
   CASE COALESCE(my_date_field,0) 
   WHEN 0 THEN 0 
   ELSE 1 END 
   AS status
  FROM 
   my_table
  </code></pre>
  
  <p><code>Error :COALESCE types timestamp without time zone and integer cannot be matched</code><br>
  <code>Line 2 : CASE COALESCE(my_date_field,0)</code> </p>
  
  <p><strong>## SOLVED ##</strong></p>
  
  <pre><code>SELECT 
    CASE WHEN my_date_field IS NULL 
    THEN 0 ELSE 1 END 
    AS status
  FROM 
    my_table
  </code></pre>
  
  <p><strong>COALESCE</strong> accepts pretty much any number of parameters, but they should be the <strong>same data-type</strong>.<br>
  I quoted from <a href="https://stackoverflow.com/questions/13366488/coalesce-function-in-tsql">COALESCE Function in TSQL</a>  </p>