質問編集履歴
2
nameの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,34 +3,35 @@
|
|
3
3
|
```TABLE1作成
|
4
4
|
CREATE TABLE TABLE1 (
|
5
5
|
code varchar(5) not null,
|
6
|
-
receipt varcar(10) not null,
|
6
|
+
receipt varchar(10) not null,
|
7
|
-
branchNum int not null
|
7
|
+
branchNum int not null,
|
8
|
+
name varchar(10) not null
|
8
9
|
);
|
9
10
|
```
|
10
11
|
使用DB:Oracle 11g
|
11
12
|
|
12
13
|
```TABLE1データ
|
13
|
-
INSERT INTO TABLE1 (code, receipt, branchNum) VALUES ('1000', 'A001', 1);
|
14
|
+
INSERT INTO TABLE1 (code, receipt, branchNum, name) VALUES ('1000', 'A001', 1, '田本');
|
14
|
-
INSERT INTO TABLE1 (code, receipt, branchNum) VALUES ('1000', 'A001', 2);
|
15
|
+
INSERT INTO TABLE1 (code, receipt, branchNum, name) VALUES ('1000', 'A001', 2, '田中');
|
15
|
-
INSERT INTO TABLE1 (code, receipt, branchNum) VALUES ('1000', 'A001', 3);
|
16
|
+
INSERT INTO TABLE1 (code, receipt, branchNum, name) VALUES ('1000', 'A001', 3, '山田');
|
16
|
-
INSERT INTO TABLE1 (code, receipt, branchNum) VALUES ('1000', 'B001', 1);
|
17
|
+
INSERT INTO TABLE1 (code, receipt, branchNum, name) VALUES ('1000', 'B001', 1, '竹田');
|
17
|
-
INSERT INTO TABLE1 (code, receipt, branchNum) VALUES ('1000', 'B001', 2);
|
18
|
+
INSERT INTO TABLE1 (code, receipt, branchNum, name) VALUES ('1000', 'B001', 2, '内田');
|
18
|
-
INSERT INTO TABLE1 (code, receipt, branchNum) VALUES ('2000', 'A001', 1);
|
19
|
+
INSERT INTO TABLE1 (code, receipt, branchNum, name) VALUES ('2000', 'A001', 1, '田所');
|
19
|
-
INSERT INTO TABLE1 (code, receipt, branchNum) VALUES ('2000', 'C001', 1);
|
20
|
+
INSERT INTO TABLE1 (code, receipt, branchNum, name) VALUES ('2000', 'C001', 1, '田井');
|
20
21
|
```
|
21
22
|
|
22
23
|
### 実現したいこと
|
23
24
|
code と receipt を軸に集計をし、branchNumが最小の値のみを抜き出したいです。
|
24
25
|
|
25
26
|
```SELECTしたいデータ
|
26
|
-
+------+--------+------------+
|
27
|
+
+------+--------+------------+------+
|
27
|
-
| code | receipt | branchNum |
|
28
|
+
| code | receipt | branchNum | name |
|
28
|
-
+------+--------+------------+
|
29
|
+
+------+--------+------------+------+
|
29
|
-
| 1000 | A001 | 1 |
|
30
|
+
| 1000 | A001 | 1 | 田本 |
|
30
|
-
| 1000 | B001 | 1 |
|
31
|
+
| 1000 | B001 | 1 | 竹田 |
|
31
|
-
| 2000 | A001 | 1 |
|
32
|
+
| 2000 | A001 | 1 | 田所 |
|
32
|
-
| 2000 | C001 | 1 |
|
33
|
+
| 2000 | C001 | 1 | 田井 |
|
33
|
-
+------+--------+------------+
|
34
|
+
+------+--------+------------+------+
|
34
35
|
```
|
35
36
|
|
36
37
|
|
1
a
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
branchNum int not null
|
8
8
|
);
|
9
9
|
```
|
10
|
+
使用DB:Oracle 11g
|
10
11
|
|
11
12
|
```TABLE1データ
|
12
13
|
INSERT INTO TABLE1 (code, receipt, branchNum) VALUES ('1000', 'A001', 1);
|