title: Case When statement with dates
body: <p>My case when statement seems to be incorrect and I cant figure out what is wrong. It gives me the same dates for both create time and update time records.
  here is how my data looks:</p>
  
  <p>T1:   </p>
  
  <pre><code>ID      create_time  
  1      08/09/2016 07:30:20AM
  </code></pre>
  
  <p>T2:  </p>
  
  <pre><code>ID   update_time  
  1      
  1   08/15/2016 09:41:46AM 
  </code></pre>
  
  <p>I am expecting the following:  </p>
  
  <pre><code>ID  TimeStamp  
  1   08/09/2016 07:30:20AM  
  1   08/15/2016 09:41:46AM
  </code></pre>
  
  <p>however my code returns values for create times for the 2 records. it looks like this:   </p>
  
  <pre><code>ID  TimeStamp  
  1   08/09/2016 07:30:20AM  
  1   08/09/2016 07:30:20AM
  
  select t1.id, t1.desc,
  Case
  WHEN t1.create_time IS NOT NULL
  THEN t1.create_time
  WHEN t2.update_time IS NOT NULL
  THEN t2.update_time
  END AS "TimeStamp"
  from t1, t2
  where t1.id=t2.id
  AND ( t1.create_time BETWEEN TO_DATE ('01-AUG-2016 00:00:00',
                                 'dd-mon-yyyy HH24:Mi:SS')
                 AND TO_DATE ('31-AUG-2016 23:59:59',
                              'dd-mon-yyyy HH24:Mi:SS')
     OR (  t2.update_time
                 BETWEEN TO_DATE ('01-AUG-2016 00:00:00',
                                  'dd-mon-yyyy HH24:Mi:SS')
                 AND TO_DATE ('31-AUG-2016 23:59:59',
                              'dd-mon-yyyy HH24:Mi:SS')
              )
          )
  </code></pre>
  
  <p>I also need to mark each record based on the create/update time as New/Update in a separate column. I was doing this using case when as below:</p>
  
  <pre><code>CASE 
  WHEN (t1.create_time IS NOT NULL AND t2.update_time IS NULL)
  THEN 'New'
  WHEN t2.update_time IS NOT NULL
  THEN 'Update'
  END AS "Type"
  </code></pre>
  
  <p>but this seems to be bringing duplicates as follows:<br>
  ID  TimeStamp    Type<br>
  1   08/09/2016   New<br>
  1   08/09/2016   Update<br>
  1   08/15/2016   New<br>
  1   08/15/2016   Update  </p>