title: Calculate time difference for attendance
body: <p>I have a table with the below sample output.</p>
  
  <pre><code>UserID  Checktime              CheckStatus
  3175    2013-12-22 07:02:10.000     I
  3175    2013-12-22 13:01:01.000     O
  3175    2013-12-22 13:49:54.000     I
  3175    2013-12-22 13:49:55.000     I
  3175    2013-12-22 15:58:42.000     O
  3175    2013-12-23 06:02:58.000     I
  3175    2013-12-23 14:00:29.000     O
  3175    2013-12-24 05:17:09.000     I
  3175    2013-12-24 12:34:25.000     O
  3175    2013-12-24 12:34:26.000     O
  </code></pre>
  
  <p>I want to build a query to achieve the below results:</p>
  
  <pre><code>UserID  Date       CheckIn   CheckOut Hours
  3175    2013-12-22 07:02:10  13:01:0  5.98
  3175    2013-12-22 13:49:54  15:58:42 2.15
  </code></pre>
  
  <p>Notice:
  1. The duplicate IN is ignored.Third and fourth lines in the raw data.
  2. Minutes are in decimal point to the hour in the hours calculation.</p>
  
  <p>I need help of the tsql query to use to get these results.</p>
  
  <p>My current code is causing lots of other issues - because it has to be recalculated in temporary tables everytime.</p>