回答編集履歴
1
chousei
test
CHANGED
@@ -13,3 +13,29 @@
|
|
13
13
|
from ken as t1
|
14
14
|
|
15
15
|
```
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
もしくは
|
20
|
+
|
21
|
+
```SQL
|
22
|
+
|
23
|
+
select t1.id as ken_id,
|
24
|
+
|
25
|
+
t1.name as ken_name,
|
26
|
+
|
27
|
+
coalesce(t2.cnt,0) as cnt
|
28
|
+
|
29
|
+
from ken as t1
|
30
|
+
|
31
|
+
left join (select ken_id,count(*) as cnt from member where
|
32
|
+
|
33
|
+
sex='男'
|
34
|
+
|
35
|
+
group by ken_id
|
36
|
+
|
37
|
+
) as t2
|
38
|
+
|
39
|
+
on t1.id=t2.ken_id
|
40
|
+
|
41
|
+
```
|