Oracle CROSS JOIN example

笛卡尔积:
insert into t_sales_forecast
select SALES_FORECAST_SEQUENCE.nextval as id,basic.* from 
(
select school_id,district_id,year_table.year,month_table.month ,500 as or_forcast,1000 as re_forcast,sysdate as update_date,'1' as user_id,sysdate as insert_date
from v_school_district
cross join 
(
select level as year from dual  where level>2006 connect by level<2012
) year_table
cross join 
(
select lpad(level,2,0) month from dual connect by level <13 
) month_table
order by school_id,district_id,year_table.year,month_table.month 
) basic

你可能感兴趣的:(oracle,sql)