Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Grouping by time intervals
I have a table with a bunch of rows that all have date fields. I would
like to be able to do an extract where I can summarize some values by
pre-defined time periods. The time periods that I am particular looking
for are 10,15,30 and 60 but the time interval could also be multiples of
hours like ever 2 hours, every 8 hours, etc.. Thus, if I summarized by 15 minutes, my times would look like:
03/21/2002 09:00 <count> 03/21/2002 09:15 <count> 03/21/2002 09:30 <count> 03/21/2002 09:45 <count>
and if I sent for two hour intervals it would look like
03/21/2002 0900 <count> 03/21/2002 1100 <count> 03/21/2002 1300 <count> 03/21/2002 1500 <count>
Is there any good, elegant way of doing this that is easy to modify whenever I want to change the time interval and can be expressed as a single algorithm regardless of whether I want intervals within hours or multiples of hours?
Ultimately the query will be in a stored procedure and I'll pass the time interval in as a parameter expressed in minutes. So, the value could be anything from 1 to 1440
TIA Received on Sat Mar 23 2002 - 05:44:53 CST