title: SQL/Oracle Grouping Data by field by hours for a certain type on a given day
body: <p>Okay trying to construct a single query to save myself a whole bunch of time (rather than writing a ton of seperate queries), but I don't even know how to start on this. </p>
  
  <p>What I need to is look at <code>single day and type</code> and break out counts on actions, by hour, between 8:00am - 8:00pm.  So for example I have the following fake table</p>
  
  <pre><code>TYPE_   ACTION_     TIMESTAMP_
  ------------------------------
  A       processed   2010-11-19 10:00:00.000
  A       processed   2010-11-19 10:46:45.000
  A       processed   2010-11-19 11:46:45.000
  A       processed   2010-11-19 12:46:45.000
  A       processed   2010-11-19 12:48:45.000
  A       pending     2010-11-19 11:46:45.000
  A       pending     2010-11-19 11:50:45.000
  A       pending     2010-11-19 12:46:45.000
  A       pending     2010-11-19 12:48:45.000
  B       pending     2010-11-19 19:48:45.000
  B       pending     2010-11-19 21:46:45.000
  .etc
  </code></pre>
  
  <p>So if I wanted to look at all records with</p>
  
  <ul>
  <li>TYPE_ = 'A'</li>
  <li>on date 2010-11-19</li>
  <li>grouped by ACTION_ per hour</li>
  </ul>
  
  <p>I would see this result</p>
  
  <pre><code>ACTION_ NUMOCCURENCES   RANGE
  ---------------------------------------------
  processed  2                10:00:00 - 11:00:00
  pending    0                10:00:00 - 11:00:00
  processed  1                11:00:00 - 12:00:00
  pending    2                11:00:00 - 12:00:00
  processed  2                12:00:00 - 13:00:00
  pending    2                12:00:00 - 13:00:00
  </code></pre>
  
  <p>Or something similar to that, but that should at least give an idea of what I am looking for. </p>
  
  <p>Can anyone help?  Normally I would try to provide some sample code I'm working with, but I have no idea how I would work with the group by clauses needed to make this happen.</p>