-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount_daily_saved_content.sql
32 lines (31 loc) · 1.14 KB
/
count_daily_saved_content.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- 1日のコンテンツ保存数を取得する(期間は直近1週間)
SELECT *
FROM
(
SELECT count(*) as today FROM content
WHERE created_at::date = now()::date
) as today,
(
SELECT count(*) as one_day_ago FROM content
WHERE created_at::date = (now()::date + cast( '-1 days' as INTERVAL ))
) as one_day_ago,
(
SELECT count(*) as two_day_ago FROM content
WHERE created_at::date = (now()::date + cast( '-2 days' as INTERVAL ))
) as two_day_ago,
(
SELECT count(*) as three_day_ago FROM content
WHERE created_at::date = (now()::date + cast( '-3 days' as INTERVAL ))
) as three_day_ago,
(
SELECT count(*) as four_day_ago FROM content
WHERE created_at::date = (now()::date + cast( '-4 days' as INTERVAL ))
) as four_day_ago,
(
SELECT count(*) as five_day_ago FROM content
WHERE created_at::date = (now()::date + cast( '-5 days' as INTERVAL ))
) as five_day_ago,
(
SELECT count(*) as six_day_ago FROM content
WHERE created_at::date = (now()::date + cast( '-6 days' as INTERVAL ))
) as six_day_ago