title: How to sum and group for specific period of time
body: <p>I have 30 min data and would like to sum hours and group by daytime from 02:00 AM of current date to 02:00 AM next date, how can I do that?:</p>
  
  <pre><code>create table test (code varchar2(50), hour number, daytime date); 
  
  insert into test (code, hour, daytime) values ('K11','0.5','23-Feb-17')
  insert into test (code, hour, daytime) values ('K11','0.5','23-02-17 00:30')
  insert into test (code, hour, daytime) values ('K11','0.5','23-02-17 01:00')
  insert into test (code, hour, daytime) values ('K11','0.5','23-02-17 01:30')
  insert into test (code, hour, daytime) values ('K11','0.5','23-02-17 02:00')
  insert into test (code, hour, daytime) values ('K11','0.5','23-02-17 02:30')
  insert into test (code, hour, daytime) values ('K11','0.5','24-Feb-17')
  insert into test (code, hour, daytime) values ('K11','0.5','24-02-17 00:30')
  insert into test (code, hour, daytime) values ('K11','0.5','24-02-17 01:00')
  insert into test (code, hour, daytime) values ('K11','0.5','24-02-17 01:30')
  insert into test (code, hour, daytime) values ('K11','0.5','24-02-17 02:00')
  insert into test (code, hour, daytime) values ('K11','0.5','24-02-17 02:30')
  insert into test (code, hour, daytime) values ('K12','0.5','23-Feb-17')
  insert into test (code, hour, daytime) values ('K12','0.5','23-02-17 00:30')
  insert into test (code, hour, daytime) values ('K12','0.5','23-02-17 01:00')
  insert into test (code, hour, daytime) values ('K12','0.5','23-02-17 01:30')
  insert into test (code, hour, daytime) values ('K12','0.5','23-02-17 02:00')
  insert into test (code, hour, daytime) values ('K12','0.5','23-02-17 02:30')
  insert into test (code, hour, daytime) values ('K12','0.5','24-Feb-17')
  insert into test (code, hour, daytime) values ('K12','0.5','24-02-17 00:30')
  insert into test (code, hour, daytime) values ('K12','0.5','24-02-17 01:00')
  insert into test (code, hour, daytime) values ('K12','0.5','24-02-17 01:30')
  insert into test (code, hour, daytime) values ('K12','0.5','24-02-17 02:00')
  insert into test (code, hour, daytime) values ('K12','0.5','24-02-17 02:30')
  </code></pre>
  
  <p>at end I'd like to get following data:</p>
  
  <pre><code>'K11',3,'23-02-17'
  'K12',3,'23-02-17'
  </code></pre>
  
  <p>So it sum hours for example for K11 from ('K11','0.5','23-02-17 02:00') to ('K11','0.5','24-02-17 01:00') </p>