<p>I have a list of times in a database column (representing visits to a website).</p>

<p>I need to group them in intervals and then get a 'cumulative frequency' table of those dates.</p>

<p>For instance I might have:</p>

<pre><code>9:01
9:04
9:11
9:13
9:22
9:24
9:28
</code></pre>

<p>and i want to convert that into</p>

<pre><code>9:05 - 2
9:15 - 4
9:25 - 6
9:30 - 7
</code></pre>

<p>How can I do that? Can i even easily achieve this in SQL? I can quite easily do it in C#</p>

Create a table
```
periods
```
describing the periods you wish to divide the day up into.
```
```
SELECT periods.name, count(time)
  FROM periods, times
 WHERE period.start <= times.time
   AND                 times.time < period.end
 GROUP BY periods.name
```
```