使用SQL Profile穩定SQL語句的執行計劃
SQL> @C:\Users\kzvz914\Desktop\AFG\coe_xfr_sql_profile.SQL
Parameter 1:
SQL_ID (required)
Enter value for 1: bbp1a0d9xkagg
PLAN_HASH_VALUE AVG_ET_SECS
--------------- -----------
3403809735 21.621
406886572 816.097
Parameter 2:
PLAN_HASH_VALUE (required)
Enter value for 2: 3403809735
生成COE_XFR_SQL_PROFILE_bbp1a0d9xkagg_3403809735.sql
SQL>@coe_xfr_sql_profile_bbp1a0d9xkagg_3403809735.sql
SQL>SET SERVEROUT ON SIZE UNL;
SQL>REM
SQL>REM $Header: 215187.1 coe_xfr_sql_profile.sql 11.4.3.5 2011/08/10 carlos.sierra $
SQL>REM
SQL>REM Copyright (c) 2000-2011, Oracle Corporation. All rights reserved.
SQL>REM
SQL>REM AUTHOR
SQL>REM
SQL>REM
SQL>REM SCRIPT
SQL>REM coe_xfr_sql_profile.sql
SQL>REM
SQL>REM DESCRIPTION
SQL>REM This script generates another that contains the commands to
SQL>REM create a manual custom SQL Profile out of a known plan from
SQL>REM memory or AWR. The manual custom profile can be implemented
SQL>REM into the same SOURCE system where the plan was retrieved,
SQL>REM or into another similar TARGET system that has same schema
SQL>REM objects referenced by the SQL that generated the known plan.
SQL>REM
SQL>REM PRE-REQUISITES
SQL>REM 1. Oracle Tuning Pack license.
SQL>REM
SQL>REM PARAMETERS
SQL>REM 1. SQL_ID (required)
SQL>REM 2. Plan Hash Value for which a manual custom SQL Profile is
SQL>REM needed (required). A list of known plans is presented.
SQL>REM
SQL>REM EXECUTION
SQL>REM 1. Connect into SQL*Plus as SYSDBA or user with access to
SQL>REM data dictionary.
SQL>REM 2. Execute script coe_xfr_sql_profile.sql passing SQL_ID and
SQL>REM plan hash value (parameters can be passed inline or until
SQL>REM requested).
SQL>REM
SQL>REM EXAMPLE
SQL>REM # sqlplus system
SQL>REM SQL> START coe_xfr_sql_profile.sql [SQL_ID] [PLAN_HASH_VALUE];
SQL>REM SQL> START coe_xfr_sql_profile.sql gnjy0mn4y9pbm 2055843663;
SQL>REM SQL> START coe_xfr_sql_profile.sql gnjy0mn4y9pbm;
SQL>REM SQL> START coe_xfr_sql_profile.sql;
SQL>REM
SQL>REM NOTES
SQL>REM 1. For possible errors see coe_xfr_sql_profile.log
SQL>REM 2. If SQLT is installed in SOURCE, you can use instead:
SQL>REM sqlt/utl/sqltprofile.sql
SQL>REM 3. Be aware that using DBMS_SQLTUNE requires a license for
SQL>REM Oracle Tuning Pack.
SQL>REM
SQL>SET TERM ON ECHO OFF;
Parameter 1:
SQL_ID (required)
Enter value for 1: bbp1a0d9xkagg
PLAN_HASH_VALUE AVG_ET_SECS
--------------- -----------
3403809735 17.007
406886572 708.367
Parameter 2:
PLAN_HASH_VALUE (required)
Enter value for 2: 3403809735
Values passed to coe_xfr_sql_profile:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SQL_ID : "bbp1a0d9xkagg"
PLAN_HASH_VALUE: " 3403809735"
SQL>WHENEVER SQLERROR EXIT SQL.SQLCODE;
SQL>
SQL>-- trim parameters
SQL>COL sql_id NEW_V sql_id FOR A30;
SQL>COL plan_hash_value NEW_V plan_hash_value FOR A30;
SQL>SELECT TRIM('&&sql_id.') sql_id, TRIM('&&plan_hash_value.') plan_hash_value FROM DUAL;
SQL_ID PLAN_HASH_VALUE
------------------------------ ------------------------------
bbp1a0d9xkagg 3403809735
SQL>
SQL>VAR sql_text CLOB;
SQL>VAR other_xml CLOB;
SQL>EXEC :sql_text := NULL;
SQL>EXEC :other_xml := NULL;
SQL>
SQL>-- get sql_text from memory
SQL>DECLARE
2 l_sql_text VARCHAR2(32767);
3 BEGIN -- 10g see bug 5017909
4 FOR i IN (SELECT DISTINCT piece, sql_text
5 FROM gv$sqltext_with_newlines
6 WHERE sql_id = TRIM('&&sql_id.')
7 ORDER BY 1, 2)
8 LOOP
9 IF :sql_text IS NULL THEN
10 DBMS_LOB.CREATETEMPORARY(:sql_text, TRUE);
11 DBMS_LOB.OPEN(:sql_text, DBMS_LOB.LOB_READWRITE);
12 END IF;
13 l_sql_text := REPLACE(i.sql_text, CHR(00), ' ');
14 DBMS_LOB.WRITEAPPEND(:sql_text, LENGTH(l_sql_text), l_sql_text);
15 END LOOP;
16 IF :sql_text IS NOT NULL THEN
17 DBMS_LOB.CLOSE(:sql_text);
18 END IF;
19 EXCEPTION
20 WHEN OTHERS THEN
21 DBMS_OUTPUT.PUT_LINE('getting sql_text from memory: '||SQLERRM);
22 :sql_text := NULL;
23 END;
24 /
SQL>
SQL>-- get sql_text from awr
SQL>BEGIN
2 IF :sql_text IS NULL OR NVL(DBMS_LOB.GETLENGTH(:sql_text), 0) = 0 THEN
3 SELECT REPLACE(sql_text, CHR(00), ' ')
4 INTO :sql_text
5 FROM dba_hist_sqltext
6 WHERE sql_id = TRIM('&&sql_id.')
7 AND sql_text IS NOT NULL
8 AND ROWNUM = 1;
9 END IF;
10 EXCEPTION
11 WHEN OTHERS THEN
12 DBMS_OUTPUT.PUT_LINE('getting sql_text from awr: '||SQLERRM);
13 :sql_text := NULL;
14 END;
15 /
SQL>
SQL>SELECT :sql_text FROM DUAL;
:SQL_TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT
'PNL-2003',
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.VIRTUAL_METRIC_CONTEXT_CODE,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_CODE,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_HIER_NAME
,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_NAME,
EDWM_AMZ_FINANCE_MD_CURRENCY2.CURRENCY_CODE,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_CODE,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_NAME,
EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE,
EDWM_AMZ_FINANCE.MD_MONTH.MONTH_NUMBER,
EDWM_AMZ_FINANCE.MD_MONTH.MONTH_DESC_SHORT,
EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_L1_NAME
,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR,
EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_NAME
,
EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END)
,
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ) - ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) )-( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END)
)-( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ),
(( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ) - ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) )),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ) - ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) )
,
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ) - ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ),
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ) - ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END) ),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
EDWM_AMZ_FINANCE.MD_MONTH.YEAR_NUMBER,
trim(to_char(EDWM_AMZ_FINANCE.MD_MONTH.MONTH_CODE,'999999')),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_M_PREV1 * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_M_PREV2 * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_M_PREV3 * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Decode(EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL,'Region',0,'Region -1',1,'Region -2',2,'Region -3',3,'Region -4',4,'Region -5',5,'Region -6',6,EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.SORT_ORDER),
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.DISPLAY_NAME,
EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_L2_Code
,
EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_L2_Name
,
EDWM_AMZ_FINANCE.MD_COST_CENTRE. COST_CENTRE_L1_Code,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'OTHERS' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE='OTHERS' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE='OTHERS' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END),
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'OTHERS' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE ) END)
FROM
EDWM_AMZ_FINANCE.MF_AFG_MONTHLY,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS,
EDWM_AMZ_FINANCE.MD_CURRENCY EDWM_AMZ_FINANCE_MD_CURRENCY2,
EDWM_AMZ_FINANCE.MD_BUDROX_RATES,
EDWM_AMZ_FINANCE.MD_MONTH,
EDWM_AMZ_FINANCE.MD_COST_CENTRE,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE,
EDWM_AMZ_FINANCE.MD_SCENARIO,
EDWM_AMZ_FINANCE.MD_BUSINESS_METRIC
WHERE
( EDWM_AMZ_FINANCE.MD_MONTH.MONTH_KEY=EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.MONTH_KEY )
AND ( EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.SCENARIO_KEY=EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_KEY )
AND ( EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_KEY=EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.COST_CENTRE_KEY )
AND ( EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.VIRTUAL_METRIC_VARIANT_KEY=EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.VIRTUAL_METRIC_VARIANT_KEY )
AND ( EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VARIANT_KEY=EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_VARIANT_KEY )
AND ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.FACT_ORG_KEY=EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.ORGANISATION_KEY )
AND ( EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.CURRENCY_KEY=EDWM_AMZ_FINANCE.MD_BUDROX_RATES.CURRENCY_KEY_BASE )
AND ( EDWM_AMZ_FINANCE.MD_BUSINESS_METRIC.BUSINESS_METRIC_KEY=EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.BUSINESS_METRIC_KEY )
AND ( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.CURRENCY_KEY_TARGET=EDWM_AMZ_FINANCE_MD_CURRENCY2.CURRENCY_KEY )
AND
(
( ( case when ( EDWM_AMZ_FINANCE.MD_BUSINESS_METRIC.BUSINESS_METRIC_CODE ) NOT IN ('OTHEREXTMARGIN') then 'Exclude OEM (WD1-3)' end ) in 'Exclude OEM (WD1-3)'
OR
'Include OEM (WD4+)' in 'Exclude OEM (WD1-3)'
:SQL_TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
)
AND
( ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_HIER_NAME
) = 'Standard Hierarchy' )
AND
( ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_KEY ) IN (SELECT /*+ no_unnest */ distinct EDWM_AMZ_FINANCE.MD_ORG_DESCENDANTS.org_unit_key_fact FROM EDWM_AMZ_FINANCE.MD_ORG_DESCENDANTS
where EDWM_AMZ_FINANCE.MD_ORG_DESCENDANTS.HIERARCHY_NAME = 'Standard Hierarchy' AND EDWM_AMZ_FINANCE.MD_ORG_DESCENDANTS.ORG_UNIT_REPORTING_CODE IN ('GBISMO'))
AND 'Standard Hierarchy'= 'Standard Hierarchy'
OR
' My Organisations' IN ('GBISMO') AND 'Standard Hierarchy' = 'Standard Hierarchy' AND ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_KEY ) IS NOT NULL
OR
( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_KEY ) IS NULL AND 'Standard Hierarchy' <> 'Standard Hierarchy' )
AND
( ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL ) IN ('Region -2')
OR
' My Reporting Level' IN ('Region -2')
AND 'Standard Hierarchy' = 'Standard Hierarchy'
AND ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL ) IN (select /*+ no_unnest */ distinct EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.organisation_level from EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS where EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_CODE
IN ('GBISMO') OR ' My Organisations' IN ('GBISMO'))
OR
' My Reporting Level' IN ('Region -2')
AND 'Standard Hierarchy' <> 'Standard Hierarchy'
AND ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL ) IN (Select /*+ no_unnest */ distinct EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.organisation_level from EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS) )
AND
( ( Case
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,7,2) = 'LB' Then 'Local (APEX)'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,7,2) = 'CB' Then 'Central (Phase1)'
End )= 'Local (APEX)' )
AND
(
( EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE In ' AUTO' OR ' AUTO' In ' AUTO' )
OR
EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE
IN ( 'ACTUAL','BUDGET' )
)
AND
(
(
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_CODE IN ( 'ALLIANCE','EXPORTS','PTRADE','SALEXF','SALGROSS','SCOREMARGIN','SALDISC','IMPORTS','REVDMD','REVEXFS' )
AND
Case
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'CA' Then 'Central Actuals'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'OA' Then 'Operational Actuals'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'EA' Then 'Early View Actuals'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'MA' Then 'Emerging Actuals'
End IN ( 'Central Actuals' )
)
OR
(
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_CODE IN ( 'CCDMDINCALL','CCEXFSINCALL','CGMDMDINCALL','CGMEXFSINCALL','VSEOSE','CCDMDINCALLEXT','CCEXFSINCALLEXT','EXTREVDMD','EXTREVEXFS' )
AND
Case
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'CA' Then 'Central Actuals'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'OA' Then 'Operational Actuals'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'EA' Then 'Early View Actuals'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'MA' Then 'Emerging Actuals'
End IN ( 'Early View Actuals' )
)
OR
(
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_CODE IN ( 'CFC','EOI','EXTERNALISATION' )
AND
Case
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'CA' Then 'Central Actuals'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'OA' Then 'Operational Actuals'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'EA' Then 'Early View Actuals'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,5,2) = 'MA' Then 'Emerging Actuals'
End IN ( 'Operational Actuals' )
)
)
AND
( ( EDWM_AMZ_FINANCE_MD_CURRENCY2.CURRENCY_CODE ) IN 'USD'
)
AND
( ( substr(EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE_MONTH_KEY,1,4) ) = (case when 'Default RoX Year' = 'Default RoX Year'
then (select to_char(edwm_amz_finance.afg_default_budrox_year.default_budrox_rates) from edwm_amz_finance.afg_default_budrox_year) else 'Default RoX Year' end) )
AND
( to_number(( trim(to_char(EDWM_AMZ_FINANCE.MD_MONTH.MONTH_CODE,'999999')) )) = (case when 'Latest Reporting Month' = 'Latest Reporting Month'
then
to_number(to_char(ADD_MONTHS(SYSDATE,-1),'yyyymm'))
else
to_number('Latest Reporting Month') end) )
)
GROUP BY
'PNL-2003',
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.VIRTUAL_METRIC_CONTEXT_CODE,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_CODE,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_HIER_NAME
,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_NAME,
EDWM_AMZ_FINANCE_MD_CURRENCY2.CURRENCY_CODE,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_CODE,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_NAME,
EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE,
EDWM_AMZ_FINANCE.MD_MONTH.MONTH_NUMBER,
EDWM_AMZ_FINANCE.MD_MONTH.MONTH_DESC_SHORT,
EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_L1_NAME
:SQL_TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR,
EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_NAME
,
EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE
,
EDWM_AMZ_FINANCE.MD_MONTH.YEAR_NUMBER,
trim(to_char(EDWM_AMZ_FINANCE.MD_MONTH.MONTH_CODE,'999999')),
Decode(EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL,'Region',0,'Region -1',1,'Region -2',2,'Region -3',3,'Region -4',4,'Region -5',5,'Region -6',6,EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.SORT_ORDER),
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.DISPLAY_NAME,
EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_L2_Code
,
EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_L2_Name
,
EDWM_AMZ_FINANCE.MD_COST_CENTRE. COST_CENTRE_L1_Code
SQL>
SQL>-- validate sql_text
SQL>SET TERM ON;
SQL>BEGIN
2 IF :sql_text IS NULL THEN
3 RAISE_APPLICATION_ERROR(-20100, 'SQL_TEXT for SQL_ID &&sql_id. was not found in memory (gv$sqltext_with_newlines) or AWR (dba_hist_sqltext).');
4 END IF;
5 END;
6 /
SQL>SET TERM OFF;
SQL>
SQL>-- to avoid errors when sql_text lacks LFs and is more than 2000 bytes
SQL>BEGIN
2 :sql_text := REPLACE(:sql_text, ')', ')'||CHR(10));
3 :sql_text := REPLACE(:sql_text, ',', ','||CHR(10));
4 -- remove consecutive LFs
5 :sql_text := REPLACE(:sql_text, CHR(10)||CHR(10)||CHR(10)||CHR(10)||CHR(10), CHR(10));
6 :sql_text := REPLACE(:sql_text, CHR(10)||CHR(10)||CHR(10), CHR(10));
7 :sql_text := REPLACE(:sql_text, CHR(10)||CHR(10), CHR(10));
8 END;
9 /
SQL>
SQL>SELECT :sql_text FROM DUAL;
:SQL_TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT
'PNL-2003',
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.VIRTUAL_METRIC_CONTEXT_CODE,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_CODE,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_HIER_NAME
,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_NAME,
EDWM_AMZ_FINANCE_MD_CURRENCY2.CURRENCY_CODE,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_CODE,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_NAME,
EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE,
EDWM_AMZ_FINANCE.MD_MONTH.MONTH_NUMBER,
EDWM_AMZ_FINANCE.MD_MONTH.MONTH_DESC_SHORT,
EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_L1_NAME
,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR,
EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_NAME
,
EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
- ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
-( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_PY_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
-( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
,
(( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
- ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'BUDGET' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
:SQL_TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU1' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
- ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
,
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'RBU2' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
- ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
,
( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
- ( Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ABU' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
EDWM_AMZ_FINANCE.MD_MONTH.YEAR_NUMBER,
trim(to_char(EDWM_AMZ_FINANCE.MD_MONTH.MONTH_CODE,
'999999')
)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_M_PREV1 * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_M_PREV2 * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'ACTUAL' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_M_PREV3 * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Decode(EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL,
'Region',
0,
'Region -1',
1,
'Region -2',
2,
'Region -3',
3,
'Region -4',
4,
'Region -5',
5,
'Region -6',
6,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.SORT_ORDER)
,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.DISPLAY_NAME,
EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_L2_Code
,
EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_L2_Name
,
EDWM_AMZ_FINANCE.MD_COST_CENTRE. COST_CENTRE_L1_Code,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'OTHERS' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE='OTHERS' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_CM * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE='OTHERS' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_FYPY * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
,
Sum(CASE WHEN EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE= 'OTHERS' AND EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.MEASURE_TYPE_NAME='Value' THEN EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VALUE_YTD * EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_COMPONENT_FACTOR*
( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.EXCHANGE_RATE )
END)
FROM
EDWM_AMZ_FINANCE.MF_AFG_MONTHLY,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC,
EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS,
EDWM_AMZ_FINANCE.MD_CURRENCY EDWM_AMZ_FINANCE_MD_CURRENCY2,
EDWM_AMZ_FINANCE.MD_BUDROX_RATES,
:SQL_TEXT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EDWM_AMZ_FINANCE.MD_MONTH,
EDWM_AMZ_FINANCE.MD_COST_CENTRE,
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE,
EDWM_AMZ_FINANCE.MD_SCENARIO,
EDWM_AMZ_FINANCE.MD_BUSINESS_METRIC
WHERE
( EDWM_AMZ_FINANCE.MD_MONTH.MONTH_KEY=EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.MONTH_KEY )
AND ( EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.SCENARIO_KEY=EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_KEY )
AND ( EDWM_AMZ_FINANCE.MD_COST_CENTRE.COST_CENTRE_KEY=EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.COST_CENTRE_KEY )
AND ( EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.VIRTUAL_METRIC_VARIANT_KEY=EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.VIRTUAL_METRIC_VARIANT_KEY )
AND ( EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.METRIC_VARIANT_KEY=EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC_STRUCTURE.METRIC_VARIANT_KEY )
AND ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.FACT_ORG_KEY=EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.ORGANISATION_KEY )
AND ( EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.CURRENCY_KEY=EDWM_AMZ_FINANCE.MD_BUDROX_RATES.CURRENCY_KEY_BASE )
AND ( EDWM_AMZ_FINANCE.MD_BUSINESS_METRIC.BUSINESS_METRIC_KEY=EDWM_AMZ_FINANCE.MF_AFG_MONTHLY.BUSINESS_METRIC_KEY )
AND ( EDWM_AMZ_FINANCE.MD_BUDROX_RATES.CURRENCY_KEY_TARGET=EDWM_AMZ_FINANCE_MD_CURRENCY2.CURRENCY_KEY )
AND
(
( ( case when ( EDWM_AMZ_FINANCE.MD_BUSINESS_METRIC.BUSINESS_METRIC_CODE )
NOT IN ('OTHEREXTMARGIN')
then 'Exclude OEM (WD1-3)
' end )
in 'Exclude OEM (WD1-3)
'
OR
'Include OEM (WD4+)
' in 'Exclude OEM (WD1-3)
'
)
AND
( ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_HIER_NAME
)
= 'Standard Hierarchy' )
AND
( ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_KEY )
IN (SELECT /*+ no_unnest */ distinct EDWM_AMZ_FINANCE.MD_ORG_DESCENDANTS.org_unit_key_fact FROM EDWM_AMZ_FINANCE.MD_ORG_DESCENDANTS
where EDWM_AMZ_FINANCE.MD_ORG_DESCENDANTS.HIERARCHY_NAME = 'Standard Hierarchy' AND EDWM_AMZ_FINANCE.MD_ORG_DESCENDANTS.ORG_UNIT_REPORTING_CODE IN ('GBISMO')
)
AND 'Standard Hierarchy'= 'Standard Hierarchy'
OR
' My Organisations' IN ('GBISMO')
AND 'Standard Hierarchy' = 'Standard Hierarchy' AND ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_KEY )
IS NOT NULL
OR
( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_KEY )
IS NULL AND 'Standard Hierarchy' <> 'Standard Hierarchy' )
AND
( ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL )
IN ('Region -2')
OR
' My Reporting Level' IN ('Region -2')
AND 'Standard Hierarchy' = 'Standard Hierarchy'
AND ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL )
IN (select /*+ no_unnest */ distinct EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.organisation_level from EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS where EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.REPORTING_ORG_CODE IN ('GBISMO')
OR ' My Organisations' IN ('GBISMO')
)
OR
' My Reporting Level' IN ('Region -2')
AND 'Standard Hierarchy' <> 'Standard Hierarchy'
AND ( EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.ORGANISATION_LEVEL )
IN (Select /*+ no_unnest */ distinct EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS.organisation_level from EDWM_AMZ_FINANCE.MH_ORGANISATION_LEVELS)
)
AND
( ( Case
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,
7,
2)
= 'LB' Then 'Local (APEX)
'
When substr(EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.virtual_metric_context_code,
7,
2)
= 'CB' Then 'Central (Phase1)
'
End )
= 'Local (APEX)
' )
AND
(
( EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE In ' AUTO' OR ' AUTO' In ' AUTO' )
OR
EDWM_AMZ_FINANCE.MD_SCENARIO.SCENARIO_CODE
IN ( 'ACTUAL',
'BUDGET' )
)
AND
(
(
EDWM_AMZ_FINANCE.MD_VIRTUAL_METRIC.BUSINESS_METRIC_CODE IN ( 'ALLIANCE',
'EXPORTS',
'PTRADE',
'SALEXF',
'SALGROSS',
'SCOREMARGIN',
'SALDISC',
'IMPORTS',
'REVDMD',
'REVEXFS' )
:SQL_TEXT
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------