반응형
with base_data as (
select '삼성제약' stock_name, '001360' stock_code, '의약품' sector_name from dual union all
select '삼성제약' stock_name, '001360' stock_code, '제조업' sector_name from dual union all
select '삼성제약' stock_name, '001360' stock_code, '소형(시가총액)' sector_name from dual union all
select '한국주철관공업' stock_name, '000970' stock_code, '철강,금속' sector_name from dual union all
select '한국주철관공업' stock_name, '000970' stock_code, '제조업' sector_name from dual union all
select '한국주철관공업' stock_name, '000970' stock_code, '소형(시가총액)' sector_name from dual union all
select '덕성' stock_name, '004830' stock_code, '제조업' sector_name from dual union all
select '덕성' stock_name, '004830' stock_code, '화학' sector_name from dual union all
select '덕성' stock_name, '004830' stock_code, '소형(시가총액)' sector_name from dual union all
select '케이티' stock_name, '030200' stock_code, '통신업' sector_name from dual union all
select '케이티' stock_name, '030200' stock_code, '코스피 200 저변동성지수' sector_name from dual union all
select '케이티' stock_name, '030200' stock_code, '코스피 200 고배당지수' sector_name from dual union all
select '케이티' stock_name, '030200' stock_code, 'KOSPI50지수' sector_name from dual union all
select '케이티' stock_name, '030200' stock_code, 'KOSPI100지수' sector_name from dual union all
select '케이티' stock_name, '030200' stock_code, 'KOSPI200지수' sector_name from dual union all
select '케이티' stock_name, '030200' stock_code, '대형(시가총액)' sector_name from dual union all
select '쎌마테라퓨틱스' stock_name, '015540' stock_code, '서비스업' sector_name from dual union all
select '쎌마테라퓨틱스' stock_name, '015540' stock_code, '소형(시가총액)' sector_name from dual union all
select '현대엘리베이터' stock_name, '017800' stock_code, '기계' sector_name from dual union all
select '현대엘리베이터' stock_name, '017800' stock_code, 'KOSPI200지수' sector_name from dual union all
select '현대엘리베이터' stock_name, '017800' stock_code, 'KOSPI200 중공업' sector_name from dual union all
select '현대엘리베이터' stock_name, '017800' stock_code, '제조업' sector_name from dual union all
select '현대엘리베이터' stock_name, '017800' stock_code, '중형(시가총액)' sector_name from dual union all
select '케이씨씨' stock_name, '002380' stock_code, '제조업' sector_name from dual union all
select '케이씨씨' stock_name, '002380' stock_code, 'KOSPI200지수' sector_name from dual union all
select '케이씨씨' stock_name, '002380' stock_code, 'KOSPI200 에너지/화학' sector_name from dual union all
select '케이씨씨' stock_name, '002380' stock_code, '대형(시가총액)' sector_name from dual union all
select '케이씨씨' stock_name, '002380' stock_code, '화학' sector_name from dual union all
select '대한화섬' stock_name, '003830' stock_code, '제조업' sector_name from dual union all
select '대한화섬' stock_name, '003830' stock_code, '화학' sector_name from dual union all
select '대한화섬' stock_name, '003830' stock_code, '소형(시가총액)' sector_name from dual union all
select '태광산업' stock_name, '003240' stock_code, '화학' sector_name from dual union all
select '태광산업' stock_name, '003240' stock_code, 'KOSPI200지수' sector_name from dual union all
select '태광산업' stock_name, '003240' stock_code, 'KOSPI200 에너지/화학' sector_name from dual union all
select '태광산업' stock_name, '003240' stock_code, '제조업' sector_name from dual union all
select '태광산업' stock_name, '003240' stock_code, '중형(시가총액)' sector_name from dual
)
select stock_name,
stock_code,
SUBSTR(
XMLAGG(
XMLELEMENT(COL ,',', sector_name) ORDER BY sector_name
).EXTRACT('//text()').GETSTRINGVAL(), 2
) as sector_names
from base_data
group by stock_name, stock_code
반응형
'DB > 오라클' 카테고리의 다른 글
ORA-12514: TNS:리스너가 현재 접속 기술자에 요청된 서비스를 알지 못함 - 해결방안 (0) | 2021.02.09 |
---|---|
오라클 기간내 월 더미Dummy 데이터 생성 (0) | 2017.04.10 |
오라클 Model 예제 (0) | 2016.12.14 |
[오라클] MIN DECODE로 행열 변환 (0) | 2016.10.22 |
리눅스에서 ORA-01861: literal does not match format string 에러 (0) | 2016.04.01 |
WRITTEN BY
,