任意时间序列数据都可以按时间分组。 timestamp 为时间戳。
按每五分钟统计日志的数目
select
floor(cast(logs.timestamp as int) / 60 / 5) as dt,
count(logs.id)
from (
select
logs.id,
logs.timestamp
from public.logs as logs
order by logs.id asc
limit 10) as logs
group by floor(cast(logs.timestamp as int) / 60 / 5);
来源:oschina
链接:https://my.oschina.net/whutzl/blog/3178366