title: SQL select & group by a period of time (timestamp)
body: <p><br>
  I want to select the count number and group by a period of time (month, week, day, hour , ...) . So for example I want to select the number of rows and group them by 24h. 
  <br>
  My table is created as follow. The date is timestamp.</p>
  
  <pre><code>CREATE TABLE MSG
  (
     MSG_ID decimal(22) PRIMARY KEY NOT NULL,
     MSG_DATE timestamp,
     FILE_REF varchar2(32),
     FILE_NAME varchar2(64),
     MSG_TYPE varchar2(2),
  );
  CREATE UNIQUE INDEX PK_FEI_MSG ON MSG(MSG_ID);
  </code></pre>
  
  <p><br>I tried with this query. With length depending on the time period. But how can I group from now . </p>
  
  <pre><code>SELECT substr(MSG_DATE, 1,length),COUNT(*) as total FROM MSG GROUP BY substr(MSG_DATE, 1, length)
  </code></pre>
  
  <p><br>
  But how can I group the date from now + time_period ?</p>