title: How to merge two different rows based on one column value in SQL Server?
body: <p>I have a result set which returns results like this,</p>
  
  <pre><code>   ID     Q_Number      INC_Date1       INC_Date2             OUT_Date1        OUT_Date2
  --------------------------------------------------------------------------------------
  8322445  Q8322445  2014-03-06 00:00:00  2014-05-14 13:31:00    NULL          NULL
  8322445  Q8322445         NULL            NULL           2014-05-16 09:22:00  2014-05-20 07:29:00
  </code></pre>
  
  <p>Actually I want to get the date difference between all the columns. </p>
  
  <p>It works for difference between INC_Date 2 and INC_Date1, OUT_Date2 and OUT_Date1 but it does not work for OUT_Date1 - INC_Date2.</p>
  
  <p>I'm not sure if taking max of the dates will work out for the entire table.</p>
  
  <p>Here is a sample of output that I want,</p>
  
  <pre><code>ID     Q_Number      INC1INC2Diff       INC2OUT1Diff         OUT1OUT2Diff 
  ----------------------------------------------------------------------------
  8322445  Q8322445       69                 1                    3
  </code></pre>
  
  <p>How can I do this?</p>