回答編集履歴
1
追記
test
CHANGED
@@ -19,3 +19,27 @@
|
|
19
19
|
order by usr.user_id
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
または
|
24
|
+
|
25
|
+
```SQL
|
26
|
+
|
27
|
+
select usr.user_id, usr.name, act.action_id, act.date, act.action
|
28
|
+
|
29
|
+
from user usr left join action act
|
30
|
+
|
31
|
+
on usr.user_id=act.user_id
|
32
|
+
|
33
|
+
where (act.date, act.action_id) in (
|
34
|
+
|
35
|
+
select max(date), max(action_id) from action
|
36
|
+
|
37
|
+
where user_id=usr.user_id and date>=act.date
|
38
|
+
|
39
|
+
)
|
40
|
+
|
41
|
+
or act.action_id is null
|
42
|
+
|
43
|
+
order by usr.user_id
|
44
|
+
|
45
|
+
```
|