title: How to group time column into 5 second intervals and count rows using Presto?
body: <p>I am using Presto and Zeppelin. There are a lot of raw datas.
  I have to summarize those datas.</p>
  
  <p>I wanna group time every 5 seconds.</p>
  
  <pre><code>serviceType        logType     date
  ------------------------------------------------------
  service1           log1        2017-10-24 23:00:23.206
  service1           log1        2017-10-24 23:00:23.207
  service1           log1        2017-10-24 23:00:25.206
  service2           log1        2017-10-24 23:00:24.206
  service1           log2        2017-10-24 23:00:27.206
  service1           log2        2017-10-24 23:00:29.302
  </code></pre>
  
  <p>then the result</p>
  
  <pre><code>serviceType        logType     date                       cnt
  --------------------------------------------------------------
  service1           log1        2017-10-24 23:00:20          2
  service2           log1        2017-10-24 23:00:20          1
  service1           log1        2017-10-24 23:00:25          1
  service1           log2        2017-10-24 23:00:25          2
  </code></pre>
  
  <p>first, I have to migrate stored datas to new tables.</p>
  
  <p>second, I have to group datas and save to the new table realtime.</p>
  
  <p>It's hard to write sql script.</p>
  
  <p>Please help me.</p>
  
  <p>Do I have to use python interpreter?</p>