質問するログイン新規登録

回答編集履歴

1

追記

2019/02/14 13:18

投稿

sazi
sazi

スコア25430

answer CHANGED
@@ -8,4 +8,16 @@
8
8
  )
9
9
  ) act on usr.user_id=act.user_id
10
10
  order by usr.user_id
11
+ ```
12
+ または
13
+ ```SQL
14
+ select usr.user_id, usr.name, act.action_id, act.date, act.action
15
+ from user usr left join action act
16
+ on usr.user_id=act.user_id
17
+ where (act.date, act.action_id) in (
18
+ select max(date), max(action_id) from action
19
+ where user_id=usr.user_id and date>=act.date
20
+ )
21
+ or act.action_id is null
22
+ order by usr.user_id
11
23
  ```