回答編集履歴
2
誤解を招く表現を修正
answer
CHANGED
@@ -6,13 +6,13 @@
|
|
6
6
|
①
|
7
7
|
```SQL
|
8
8
|
//最新ログインが本日
|
9
|
-
where DATE(current_sign_in_at)=DATE(NOW());
|
9
|
+
select * from users where DATE(current_sign_in_at)=DATE(NOW());
|
10
10
|
|
11
11
|
//〃3日以内
|
12
|
-
where DATE(current_sign_in_at) between DATE(NOW()) - interval 3 day and DATE(NOW());
|
12
|
+
select * from users where DATE(current_sign_in_at) between DATE(NOW()) - interval 3 day and DATE(NOW());
|
13
13
|
|
14
14
|
//〃1週間以内
|
15
|
-
where DATE(current_sign_in_at) between DATE(NOW()) - interval 7 day and DATE(NOW());
|
15
|
+
select * from users where DATE(current_sign_in_at) between DATE(NOW()) - interval 7 day and DATE(NOW());
|
16
16
|
```
|
17
17
|
②
|
18
18
|
```SQL
|
1
追記
answer
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
既に回答ついてますが多分こんな感じかと。
|
2
2
|
|
3
|
+
追記
|
4
|
+
日付が時分秒含むみたいなので時分秒抜いて(日付部分とだけで)チェックするように変更
|
5
|
+
|
3
6
|
①
|
4
7
|
```SQL
|
5
8
|
//最新ログインが本日
|
6
|
-
where current_sign_in_at=DATE(NOW());
|
9
|
+
where DATE(current_sign_in_at)=DATE(NOW());
|
7
|
-
//current_sign_in_at が時分秒まで含む場合
|
8
|
-
where current_sign_in_at between DATE(NOW()) and DATE(NOW()) + interval 1 day;
|
9
10
|
|
10
11
|
//〃3日以内
|
11
|
-
where current_sign_in_at between DATE(NOW()) - interval 3 day and DATE(NOW());
|
12
|
+
where DATE(current_sign_in_at) between DATE(NOW()) - interval 3 day and DATE(NOW());
|
12
13
|
|
13
14
|
//〃1週間以内
|
14
|
-
where current_sign_in_at between DATE(NOW()) - interval 7 day and DATE(NOW());
|
15
|
+
where DATE(current_sign_in_at) between DATE(NOW()) - interval 7 day and DATE(NOW());
|
15
16
|
```
|
16
17
|
②
|
17
18
|
```SQL
|