回答編集履歴
1
更新
answer
CHANGED
@@ -5,12 +5,13 @@
|
|
5
5
|
create table b_tbl (id int, name text);
|
6
6
|
create table c_tbl (id int, member_id int, comment text, checkorder int);
|
7
7
|
|
8
|
-
select
|
8
|
+
select t9.adate as date, t9.ahour as hour, t9.category, t8.name, t7.comment from a_tbl t9
|
9
|
+
join
|
9
|
-
(select t5.adate, t5.ahour, t5.member_id, t6.comment, t5.category from a_tbl t5
|
10
|
+
(select t5.adate, min(t5.ahour) as ahour, t5.member_id, t6.comment, t5.category from a_tbl t5
|
10
11
|
join ( select * from c_tbl t3 join (select t1.member_id, max(id) as id from c_tbl t1
|
11
12
|
join (select member_id, max(checkorder) as checkorder from c_tbl group by member_id) t2
|
12
13
|
using(member_id,checkorder) group by 1) t4
|
13
14
|
using(member_id,id)) t6 using (member_id) group by t5.member_id) t7
|
15
|
+
using(adate,ahour,member_id)
|
14
16
|
join b_tbl t8 on t8.id=t7.member_id;
|
15
|
-
|
16
17
|
```
|