回答編集履歴
3
修正
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
```SQL
|
4
4
|
|
5
|
-
select A.CODE, sum(iif(A.Afield < B.Bfield, 1, 0))
|
5
|
+
select A.CODE, sum(iif(A.Afield < B.Bfield, 1, 0)) as cnt
|
6
6
|
|
7
7
|
from tableA as A inner join tableB as B
|
8
8
|
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
```SQL
|
22
22
|
|
23
|
-
select sum(iif(A.Afield < B.Bfield, 1, 0))
|
23
|
+
select sum(iif(A.Afield < B.Bfield, 1, 0)) as cnt
|
24
24
|
|
25
25
|
from tableA as A inner join tableB as B
|
26
26
|
|
2
修正
test
CHANGED
@@ -8,8 +8,24 @@
|
|
8
8
|
|
9
9
|
on A.CODE=B.CODE
|
10
10
|
|
11
|
-
where A.CODE=111
|
12
|
-
|
13
11
|
group by A.CODE
|
14
12
|
|
15
13
|
```
|
14
|
+
|
15
|
+
※```on A.CODE=B.CODE```は結合条件なので、実際とは違うかもしれません
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
上記はすべてのデータの一覧なので、コードをピンポイントで指定した場合は、group byは不要です。
|
20
|
+
|
21
|
+
```SQL
|
22
|
+
|
23
|
+
select sum(iif(A.Afield < B.Bfield, 1, 0))
|
24
|
+
|
25
|
+
from tableA as A inner join tableB as B
|
26
|
+
|
27
|
+
on A.CODE=B.CODE
|
28
|
+
|
29
|
+
where A.CODE=111
|
30
|
+
|
31
|
+
```
|
1
修正
test
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
|
9
9
|
on A.CODE=B.CODE
|
10
10
|
|
11
|
+
where A.CODE=111
|
12
|
+
|
11
13
|
group by A.CODE
|
12
14
|
|
13
15
|
```
|