回答編集履歴
2
コード修正
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
FROM (
|
10
10
|
|
11
|
-
select id, name
|
11
|
+
select id, name n1, null n2, null n3 , null n4 from mybook
|
12
12
|
|
13
13
|
union all select id, null, name, null, null from mybook2
|
14
14
|
|
1
コード微修正
test
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
```sql
|
6
6
|
|
7
|
-
SELECT base.id, max(n
|
7
|
+
SELECT base.id, max(n1) name1, max(n2) name2, max(n3) name3, max(n4) name4
|
8
8
|
|
9
9
|
FROM (
|
10
10
|
|
11
|
-
select id, name as n
|
11
|
+
select id, name as n1, null as n2, null as n3 , null as n4 from mybook
|
12
12
|
|
13
13
|
union all select id, null, name, null, null from mybook2
|
14
14
|
|
@@ -16,8 +16,8 @@
|
|
16
16
|
|
17
17
|
union all select id, null, null, null, name from mybook4
|
18
18
|
|
19
|
-
|
19
|
+
) base
|
20
20
|
|
21
|
-
group by id;
|
21
|
+
group by id;
|
22
22
|
|
23
23
|
```
|