title: sql number of times computer is active
body: <p>I am trying to make a query on a postgresql 9.1 table with the two relevant columns being:</p>
  
  <pre><code>occurred - timestamp with timezone
  computer - varchar
  </code></pre>
  
  <p>Assume that the table covers a 24 hour period from midnight to midnight and i need to get a 24 length list where each element is the count of rows that <em>one</em> computer had during that hour of the day. I will have the computer name for the <code>WHERE</code> clause.</p>
  
  <p>Here is my sql so far:</p>
  
  <pre><code>select extract(hour from occurred) as hr, count(where computer = "computername") 
      from tablename group by extract(hour from occurred) order by 1
  </code></pre>