Таблица умножения:
- select * from
- (
- SELECT *
- FROM dual d
- MODEL
- DIMENSION BY (1 x,1 y)
- MEASURES (1 mpl)
- RULES ITERATE (100) (
- mpl[
- trunc(iteration_number/10)+1,
- mod(iteration_number,10)+1
- ] = (trunc(iteration_number/10)+1)*(mod(iteration_number,10)+1)
- )
- )
- pivot(
- sum(mpl)
- for (y) in (1,2,3,4,5,6,7,8,9,10)
- )
- order by x
* This source code was highlighted with Source Code Highlighter.
Генерация дат для групп:
with facility_month as (
select 'F001' facility,to_date('1/1/2008','mm/dd/yyyy') eff_month from dual union all
select 'F001',to_date('2/1/2008','mm/dd/yyyy') from dual union all
select 'F001',to_date('3/1/2008','mm/dd/yyyy') from dual union all
select 'F001',to_date('4/1/2008','mm/dd/yyyy') from dual union all
select 'F001',to_date('5/1/2008','mm/dd/yyyy') from dual union all
select 'F001',to_date('6/1/2008','mm/dd/yyyy') from dual union all
select 'F001',to_date('7/1/2008','mm/dd/yyyy') from dual union all
select 'F002',to_date('4/1/2008','mm/dd/yyyy') from dual union all
select 'F002',to_date('5/1/2008','mm/dd/yyyy') from dual union all
select 'F002',to_date('6/1/2008','mm/dd/yyyy') from dual union all
select 'F002',to_date('7/1/2008','mm/dd/yyyy') from dual union all
select 'F002',to_date('8/1/2008','mm/dd/yyyy') from dual union all
select 'F002',to_date('9/1/2008','mm/dd/yyyy') from dual union all
select 'F002',to_date('10/1/2008','mm/dd/yyyy') from dual
)
,t as (
select facility, min(EFF_MONTH) min
from FACILITY_MONTH f
group by facility
)
select * from t
model
partition by (facility,min)
dimension by (1 as y)
measures(sysdate as dt)
rules iterate(1000) until (dt[iteration_number]>=trunc(sysdate,'mm')) (
dt[iteration_number] = add_months(cv(min),iteration_number)
)
order by facility,y
* This source code was highlighted with Source Code Highlighter.
Comments
Отправить комментарий