title: Find number of concurrent users in a SQL records
body: <p>I have the table of following structure:</p>
  
  <pre><code>UserID   StartedOn          EndedOn
  1        2009-7-12T14:01    2009-7-12T15:01 
  2        2009-7-12T14:30    2009-7-12T14:45
  3        2009-7-12T14:47    2009-7-12T15:30
  4        2009-7-12T13:01    2009-7-12T17:01
  5        2009-7-12T14:15    2009-7-12T18:01
  6        2009-7-12T11:01    2009-7-12T19:01
  1        2009-7-12T16:07    2009-7-12T19:01
  </code></pre>
  
  <p>I need to find the maximal number of concurrent users that were on line. In the above table the result would be 5 because users set1={1,2,4,5,6} and set2={1,3,4,5,6} were online in the same period.</p>
  
  <p>Do you have an idea how one could calculate this using T-SQL only?</p>