title: sql query break into 15 minutes
body: <p>Have a table with a datetime_in, datetime_out, card_id, group. Know i want a output in the following matters:</p>
  
  <pre><code>group  ; date       ;  quarterTime    ; persons_in ; hours
  group1 ; 17-02-2010 ; 00:00 - 00:15  ; 0          ; 0
  group1 ; 17-02-2010 ; 00:15 - 00:30  ; 0          ; 0
  group1 ; 17-02-2010 ; 00:30 - 00:45  ; 0          ; 0
  ~etc
  group1 ; 17-02-2010 ; 13:00 - 12:15  ; 334        ; 1483
  
  end then the same for all the groups starting with 00:00 until 23:45
  </code></pre>
  
  <p>so for each quearter of the day i want to have a record, grouped by the group, date (in days) and quarterTime. Then in persons_in i want the record count within that quarter, and in hours how many person hours are worked in total for that day until the end of the current quarter. so that only get higher and higer per day, while the persons_in count only is within that quarter. So my question is, I now have a really dirty C# script doing this, for optimalization i want to run is in just 1 query. </p>
  
  <p>I dont mind using stored procedures, but since im not really good in sql i prefer T-SQL.</p>
  
  <p><strong>Anybody has in idea how to do this? examples?</strong></p>