--원본쿼리
with test as (
select '2001460878' as no_prod, '1000664423' as acct , '2001002187' as svc, '10' as div, 'PD41000007' as prod from dual
union all
select '2001460879' as no_prod, '1000664423' as acct , '2001002187' as svc, '20' as div, 'AN' as prod from dual
union all
select '2001460880' as no_prod, '1000664423' as acct , '2001002187' as svc, '20' as div, 'AL' as prod from dual
)
select * from test;
--원하는 결과
with test as (
select '2001460878' as no_prod, '1000664423' as acct , '2001002187' as svc, '10' as div, 'PD41000007' as prod, 'PD41000007' as base from dual
union all
select '2001460879' as no_prod, '1000664423' as acct , '2001002187' as svc, '20' as div, 'AN' as prod, 'PD41000007' as base from dual
union all
select '2001460880' as no_prod, '1000664423' as acct , '2001002187' as svc, '20' as div, 'AL' as prod, 'PD41000007' as base from dual
)
select * from test;
조회한 결과가 원본쿼리 처럼 나오는데요..
고객데이터 추출하는 건데요..
no_prod는 상품번호, acct 계정번호, svc 계약번호, div 구분(10상품, 20장비), prod는 상품명 이렇게 조회를 하게되는데요..
원하는 결과처럼 해당 계정번호의 해당계약에 대해서 조회를 할때 div가 10인 prod을 20에도 박아주고 싶은데요.
셀프조인 안하고 함수를 써서 가능할까요?
해볼라고 하는데 어려운거 같아요..ㅠㅠ