I am using Presto and Zeppelin. There are a lot of raw datas. I have to summarize those datas.
I wanna group time every 5 seconds.
serviceType log
You can
timestamp
with date_trunc
timestamp
without millisecond part to 5 seconds with ts - interval '1' second * (second(ts) % 5)
Example putting this together:
presto> SELECT ts_rounded, count(*)
-> FROM (
-> SELECT date_trunc('second', ts) - interval '1' second * (second(ts) % 5) AS ts_rounded
-> FROM (VALUES timestamp '2017-10-24 23:01:20.206',
-> timestamp '2017-10-24 23:01:23.206',
-> timestamp '2017-10-24 23:01:23.207',
-> timestamp '2017-10-24 23:01:26.206') AS t(ts)
-> )
-> GROUP BY ts_rounded ORDER BY ts_rounded;
ts_rounded | _col1
-------------------------+-------
2017-10-24 23:01:20.000 | 3
2017-10-24 23:01:25.000 | 1
(2 rows)