回答編集履歴
4
追記
answer
CHANGED
@@ -17,4 +17,7 @@
|
|
17
17
|
on t1.id = t2.id
|
18
18
|
where t2.id is null
|
19
19
|
group by id
|
20
|
-
```
|
20
|
+
```
|
21
|
+
※こちらはnekoさんの回答に近い動作をすると思います。
|
22
|
+
|
23
|
+
それぞれの回答の実行計画をフィードバックしてくれると有難いですけど。
|
3
追記
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
相関副問合せを使用し場合
|
1
|
+
相関副問合せを使用した場合
|
2
2
|
```SQL
|
3
3
|
select id
|
4
4
|
from table_a ta
|
@@ -6,4 +6,15 @@
|
|
6
6
|
select 1 from table_a where id=ta.id and name is null
|
7
7
|
)
|
8
8
|
group by id
|
9
|
+
```
|
10
|
+
インラインビューを使用した場合
|
11
|
+
```SQL
|
12
|
+
select id
|
13
|
+
from table_a t1
|
14
|
+
left join (
|
15
|
+
select id from table_a where name is null group by id
|
16
|
+
) t2
|
17
|
+
on t1.id = t2.id
|
18
|
+
where t2.id is null
|
19
|
+
group by id
|
9
20
|
```
|
2
訂正
answer
CHANGED
@@ -1,1 +1,9 @@
|
|
1
|
+
相関副問合せを使用し場合
|
2
|
+
```SQL
|
3
|
+
select id
|
4
|
+
from table_a ta
|
1
|
-
|
5
|
+
where not exists(
|
6
|
+
select 1 from table_a where id=ta.id and name is null
|
7
|
+
)
|
8
|
+
group by id
|
9
|
+
```
|
1
推敲
answer
CHANGED
@@ -1,14 +1,1 @@
|
|
1
|
-
> サブクエリを使わず取得する方法(group byなど)ありますでしょうか?
|
2
|
-
|
3
|
-
逆になぜ態々サブクエリー使うの?と思ってしまいますが。
|
4
|
-
```SQL
|
5
|
-
|
1
|
+
編集中・・・しばらくお待ちください。
|
6
|
-
from table_a
|
7
|
-
where name is not null
|
8
|
-
```
|
9
|
-
```SQL
|
10
|
-
select id
|
11
|
-
from table_a
|
12
|
-
where name is not null
|
13
|
-
group by id
|
14
|
-
```
|