안녕하세요.
기간별 누적을 구하는 부분에서 막힘이 있어 질문드립니다.
with orgz as (
select '조직1' as orgzno, '부가정보1' etc from dual
union all
select '조직2' as orgzno, '부가정보1' etc from dual
)
, emp as (
select '사원1' as empno, '조직1' as orgzno from dual
union all
select '사원2' as empno, '조직1' as orgzno from dual
union all
select '사원3' as empno, '조직2' as orgzno from dual
union all
select '사원4' as empno, '조직2' as orgzno from dual
)
,acrs as (
select '201310' as ym, '사원1' as empno, 100 as amt from dual
union all
select '201311' as ym, '사원1' as empno, 200 as amt from dual
union all
select '201312' as ym, '사원1' as empno, 300 as amt from dual
union all
select '201311' as ym, '사원2' as empno, 400 as amt from dual
union all
select '201312' as ym, '사원3' as empno, 500 as amt from dual
)
,edct as (
select '201310' as ym, '사원1' as empno, '과정1' as crs from dual
union all
select '201310' as ym, '사원1' as empno, '과정2' as crs from dual
union all
select '201311' as ym, '사원1' as empno, '과정3' as crs from dual
union all
select '201312' as ym, '사원2' as empno, '과정1' as crs from dual
)
201312월 집계
조직 부가정보 사원 당월실적 전월누적실적 과정1수료횟수
조직1 부가정보1 사원1 300 300 1
조직1 부가정보1 사원2 0 400 0
조직2 부가정보2 사원3 500 0 1
년월을 입력받아서 위처럼 집계할수 있는방법이 있을까요...
이것 말고도 부가정보가 덕지덕지 붙어야되서 group by를 안쓰고 하고싶은데.. 가능한가요?
이렇게 기간별로 있는 데이터를 당월, 전월 누적, 특정 년월구간별로 옆으로 나열하는 방법이 뭐가 있나요?