回答編集履歴
1
追記
test
CHANGED
@@ -9,3 +9,33 @@
|
|
9
9
|
日付をつかったbetweenを取ると思った通りの期間が得られないこともあるので
|
10
10
|
|
11
11
|
注意してください
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
# 追記
|
16
|
+
|
17
|
+
created_atをなぜ日付化しているか仕様がかいていないのでわかりません
|
18
|
+
|
19
|
+
かりにcreated_atがdate型だとすると以下
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```SQL
|
24
|
+
|
25
|
+
select created_at,count(*) as c,
|
26
|
+
|
27
|
+
(select count(*) from users as t2 where created_at BETWEEN '2017-03-11' AND curdate()
|
28
|
+
|
29
|
+
AND t1.created_at>=t2.created_at
|
30
|
+
|
31
|
+
) as t
|
32
|
+
|
33
|
+
from users as t1
|
34
|
+
|
35
|
+
where created_at BETWEEN '2017-03-11' AND curdate()
|
36
|
+
|
37
|
+
group by created_at
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```
|