[Home] [Help]
MATERIALIZED VIEW: APPS.ISC_SAM_006_MV
Source
select 0 UMARKER, 'SALES REP' GRP_MARKER, fact.customer_id CUSTOMER_ID, cc.class_code CLASS_CODE, sc.resource_id RESOURCE_ID, sc.sales_grp_id SALES_GRP_ID, sc.sales_grp_id PARENT_GRP_ID, decode(grouping_id(cc.class_code, fact.customer_id),0,0,1,1,3,3) AGG_LEVEL, grouping_id( cc.class_code, fact.customer_id, sc.resource_id, sc.sales_grp_id, cal.ent_year_id, cal.ent_qtr_id, cal.ent_period_id, cal.week_id, cal.report_date_julian) GRP_ID, cal.ent_year_id, cal.ent_qtr_id, cal.ent_period_id, cal.week_id, cal.report_date_julian, decode(grouping_id(cal.ent_year_id, cal.ent_qtr_id, cal.ent_period_id, cal.week_id, cal.report_date_julian), 30, cal.report_date_julian, 29, cal.week_id, 27, cal.ent_period_id, 23, cal.ent_qtr_id, 15, cal.ent_year_id) TIME_ID, sum(decode(fact.line_category_code, 'RETURN', 0, fact.fulfilled_amt_g*sc.sales_credit_percent/100)) fulfill_amt_g, sum(decode(fact.line_category_code, 'RETURN', 0, fact.fulfilled_amt_g1*sc.sales_credit_percent/100)) fulfill_amt_g1, count(decode(fact.line_category_code, 'RETURN', 0, fact.fulfilled_amt_g*sc.sales_credit_percent/100)) c_fulfill_amt_g, count(decode(fact.line_category_code, 'RETURN', 0, fact.fulfilled_amt_g1*sc.sales_credit_percent/100)) c_fulfill_amt_g1, count(*) c_total from ISC.ISC_BOOK_SUM2_F fact, ISC.ISC_SALES_CREDITS_F sc, FII.FII_PARTY_MKT_CLASS cc, FII.FII_TIME_DAY cal where fact.time_fulfilled_date_id = cal.report_date and fact.customer_id = cc.party_id and fact.blanket_line_number is null and fact.line_id = sc.line_id and fact.line_category_code <> 'RETURN' and fact.fulfilled_flag = 'Y' and fact.order_source_id <> 10 and fact.order_source_id <> 27 and fact.ordered_quantity <> 0 and fact.unit_selling_price <> 0 and fact.charge_periodicity_code is null group by sc.resource_id, sc.sales_grp_id, rollup(cc.class_code, fact.customer_id), grouping sets(cal.ent_year_id, cal.ent_qtr_id, cal.ent_period_id, cal.week_id, cal.report_date_julian) union all select 1 UMARKER, grp.umarker GRP_MARKER, fact.customer_id CUSTOMER_ID, cc.class_code CLASS_CODE, null RESOURCE_ID, grp.prg_id SALES_GRP_ID, grp.parent_prg_id PARENT_GRP_ID, decode(grouping_id( cc.class_code, fact.customer_id),0,0,1,1,3,3) AGG_LEVEL, grouping_id( cc.class_code, fact.customer_id, grp.umarker, grp.prg_id, grp.parent_prg_id, cal.ent_year_id, cal.ent_qtr_id, cal.ent_period_id, cal.week_id, cal.report_date_julian) GRP_ID, cal.ent_year_id, cal.ent_qtr_id, cal.ent_period_id, cal.week_id, cal.report_date_julian, decode(grouping_id(cal.ent_year_id, cal.ent_qtr_id, cal.ent_period_id, cal.week_id, cal.report_date_julian), 30, cal.report_date_julian, 29, cal.week_id, 27, cal.ent_period_id, 23, cal.ent_qtr_id, 15, cal.ent_year_id) TIME_ID, sum(decode(fact.line_category_code, 'RETURN', 0, fact.fulfilled_amt_g*sc.sales_credit_percent/100)) fulfill_amt_g, sum(decode(fact.line_category_code, 'RETURN', 0, fact.fulfilled_amt_g1*sc.sales_credit_percent/100)) fulfill_amt_g1, count(decode(fact.line_category_code, 'RETURN', 0, fact.fulfilled_amt_g*sc.sales_credit_percent/100)) c_fulfill_amt_g, count(decode(fact.line_category_code, 'RETURN', 0, fact.fulfilled_amt_g1*sc.sales_credit_percent/100)) c_fulfill_amt_g1, count(*) c_total from ISC.ISC_BOOK_SUM2_F fact, ISC.ISC_SALES_CREDITS_F sc, FII.FII_PARTY_MKT_CLASS cc, oki_rs_group_mv grp, FII.FII_TIME_DAY cal where fact.time_fulfilled_date_id = cal.report_date and fact.customer_id = cc.party_id and sc.sales_grp_id = grp.rg_id and fact.blanket_line_number is null and fact.line_id = sc.line_id and fact.line_category_code <> 'RETURN' and fact.fulfilled_flag = 'Y' and fact.order_source_id <> 10 and fact.order_source_id <> 27 and fact.ordered_quantity <> 0 and fact.unit_selling_price <> 0 and fact.charge_periodicity_code is null group by grp.umarker, grp.prg_id, grp.parent_prg_id, rollup(cc.class_code, fact.customer_id), grouping sets(cal.ent_year_id, cal.ent_qtr_id, cal.ent_period_id, cal.week_id, cal.report_date_julian)