質問編集履歴
1
説明の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,4 +14,30 @@
|
|
14
14
|
|
15
15
|
inの中の値を生成するfunctionを考えましたが、
|
16
16
|
複数の値を返すfunctionとなるとどーしてもtypeの型で返してしまうのでダメですよね・・・?
|
17
|
-
何かいい方法ないでしょうか。
|
17
|
+
何かいい方法ないでしょうか。
|
18
|
+
|
19
|
+
-------追記---------
|
20
|
+
```oracle
|
21
|
+
create table test1
|
22
|
+
(
|
23
|
+
item1 varchar2(10),
|
24
|
+
item2 varchar2(10),
|
25
|
+
item3 int
|
26
|
+
)
|
27
|
+
insert into test1 VALUES('A','2015',10)
|
28
|
+
insert into test1 VALUES('A','2015',11)
|
29
|
+
insert into test1 VALUES('A','2016',12)
|
30
|
+
insert into test1 VALUES('A','2016',13)
|
31
|
+
insert into test1 VALUES('B','2015',20)
|
32
|
+
insert into test1 VALUES('B','2015',21)
|
33
|
+
insert into test1 VALUES('B','2016',22)
|
34
|
+
insert into test1 VALUES('B','2016',23)
|
35
|
+
```
|
36
|
+
例えばこのようなデータがあったとき。
|
37
|
+
やりたいことをSELECTで記載すると以下のようになります。
|
38
|
+
```oracle
|
39
|
+
select *
|
40
|
+
from test1
|
41
|
+
pivot (sum(item3) for item2 in('2015','2016'))
|
42
|
+
```
|
43
|
+
この時にinの中の文字列を直書きではなくしたいです。
|