回答編集履歴
1
変更
answer
CHANGED
@@ -7,20 +7,22 @@
|
|
7
7
|
, age.sub_val as age, address.sub_val as address
|
8
8
|
, thread_follower.follow_date, thread_follower.favorite_date
|
9
9
|
from (
|
10
|
+
select follow.actor_id
|
11
|
+
, max(
|
10
|
-
|
12
|
+
case when action.action_name='follow' then action.action_date end
|
13
|
+
) as follow_date
|
14
|
+
, max(
|
15
|
+
case when action.action_name='favorite' then action.action_date end
|
16
|
+
) as favorite_date
|
11
|
-
from
|
17
|
+
from action_datas follow
|
12
|
-
where target_type ='user' and actor_id=1 and action_name='follow'
|
13
|
-
union all
|
14
|
-
select action_name, target_id, action_date, Null
|
15
|
-
|
18
|
+
left join action_datas action
|
19
|
+
on follow.actor_id=action.target_id
|
20
|
+
and action.actor_id=1 and action.target_type='user'
|
16
|
-
where target_type
|
21
|
+
where follow.target_type='thread' and follow.target_id=20
|
17
|
-
union all
|
18
|
-
select action_name, target_id, Null, action_date
|
19
|
-
|
22
|
+
group by follow.actor_id
|
20
|
-
where target_type ='user' and actor_id=1 and action_name='favorite'
|
21
23
|
) thread_follower
|
22
24
|
left join main_datas main
|
23
|
-
on thread_follower.
|
25
|
+
on thread_follower.actor_id=main.main_id
|
24
26
|
left join sub_datas age
|
25
27
|
on main.main_id=age.user_id and age.sub_key='age'
|
26
28
|
left join sub_datas address
|