title: Complicated grouping and time difference
body: <p>So I have a log table that is putting in data like:</p>
  
  <pre><code>LogId   SiteNumber  Unit        IDNumber    LogCode     EnteredDateTime            ChangeMode           HowEntered
  -----   ----------  ----        --------    -------     ----------------           ----------           -----------
  851     1           16 - 0      23502       BDISCHSET   2011-11-12 11:48:08.890    Discharging Soon     SERIES
  866     1           16 - 0      NULL        BDISCHRED   2011-11-12 21:45:11.657    Discharged           SERIES  
  113     2           2001 - 0    12384       BDISCHSET   2011-10-28 09:27:08.773    Discharging Soon     SERIES
  125     2           2001 - 0    NULL        BDISCHRED   2011-10-28 10:38:08.060    Discharged           SERIES
  119     2           2002 - 0    12394       BDISCHSET   2011-10-28 10:01:12.443    Discharging Soon     SERIES
  139     2           2002 - 0    NULL        BDISCHRED   2011-10-28 14:01:11.120    Discharged           SERIES
  776     2           2002 - 0    12331       BDISCHSET   2011-11-10 09:08:09.443    Discharging Soon     SERIES
  783     2           2002 - 0    NULL        BDISCHRED   2011-11-10 11:08:08.537    Discharged           SERIES
  </code></pre>
  
  <p>What I need to do is group the records per person and calculate the amount of time it took to discharge.</p>
  
  <p>For example:
  Unit 2002 - 0 has two different people to group, it would be:</p>
  
  <p>Person 12394 10/28/2011 from 10:01 to 14:01 = 4 hours to discharge</p>
  
  <p>Person 12331 11/10/2011 from  9:08 to 11:08 = 2 hours to discharge</p>
  
  <p>Any help would be greatly appreciated. </p>