2
私はこのような時間帯で12時間の期間と別の結果を得るためのテーブルからのカウント(*)を選択します:選択クエリ
time | count
00:00 - 03:00 | 12
03:00 - 06:00 | 25
etc...
私が好きなものを書いた:
select
timestamp,
row_number() over (partition by timestamp order by count(*) desc) as score
from logs
where to_timestamp(timestamp) between symmetric now() and now() - interval '12 hours'
group by timestamp
order by score desc;
それは、すべてのタイムスタンプ記録に分離:
timestamp | score
1466330486.813 | 25
正しく期間を統一する方法?
SELECT
date_trunc('hour', timestamp),
count(*) as score
FROM logs
GROUP BY date_trunc('hour', timestamp);
date_trunc
ドキュメントis here:あなたは毎時解像度に慣れている場合