with test_table as (select 'a000' as item_code ,'수요' as data_type ,40 as date_01 ,10 as date_02 ,83 as date_03 from dual union all
select 'a000' as item_code ,'공급' as data_type ,10 as date_01 ,50 as date_02 ,20 as date_03 from dual union all
select 'a001' as item_code ,'수요' as data_type ,30 as date_01 ,11 as date_02 ,67 as date_03 from dual union all
select 'a001' as item_code ,'공급' as data_type ,88 as date_01 ,19 as date_02 ,91 as date_03 from dual union all
select 'a002' as item_code ,'수요' as data_type ,73 as date_01 ,29 as date_02 ,46 as date_03 from dual union all
select 'a002' as item_code ,'공급' as data_type ,51 as date_01 ,15 as date_02 ,33 as date_03 from dual
)
select item_code
,data_type
,date_01
,date_02
,date_03
from test_table
위와 같은 data가 있습니다..
여기서 item_code 별로 Row를 하나씩 추가 하고 싶은데요
그 data는
data_type = '과부족수량'
date_01 = date_01(공급Row) - date_01(수요Row)
date_02 = date_02(공급Row) - date_02(수요Row) + date_01(과부족수량 Row --위컬럼 합계)
date_03 = date_03(공급Row) - date_03(수요Row) + date_02(과부족수량 Row --위컬럼 합계)
이런식으로 컬럼이 90개가 있습니다.
이건 진정 procedure로 해결할수 밖에 없는건가요?