시간별 통계

아래 쿼리는 하루 중 시간대별로 생성된 게시글을 보여줍니다.

-- [params]
-- int :months_ago = 1

WITH query_period AS
(SELECT date_trunc('month', CURRENT_DATE) - INTERVAL ':months_ago months' AS period_start,
                                                    date_trunc('month', CURRENT_DATE) - INTERVAL ':months_ago months' + INTERVAL '1 month' - INTERVAL '1 second' AS period_end)
SELECT EXTRACT (HOUR FROM p.created_at) AS hour,
  COUNT(p.id) AS amount
FROM posts p
JOIN topics t ON t.id = p.topic_id
JOIN query_period qp ON p.created_at >= qp.period_start
AND p.created_at <= qp.period_end
WHERE t.archetype = 'regular'
AND p.user_id > 0
GROUP BY hour
ORDER BY hour

데이터 탐색기 플러그인은 기본적으로 설치하는 플러그인 중 하나입니다. 관리자 - 플러그인에서 활성화하기만 하면 됩니다. 호스팅과 관련된 특정 질문이 있으시면 support@discoursehosting.com으로 문의해 주세요.