SELECT Q.PERSON_ID_MANAGER , %TrimSubstr(Q.TIMEFRAME_ID , 1,15) %Concat '-' %Concat %TrimSubstr(Q.PERIOD_ROLLUP_ID , 1,15) , Q.TIMEFRAME_ID , Q.PERIOD_ROLLUP_ID , INST.PT_CDB_DEF_CUR_CD , %Round(SUM(%DecMult(CUR.INST_MULT , REVENUE_AMOUNT)),0) FROM PS_RSF_PLQR_R1_VW Q , PS_RSFD_TFP_VW TF , PSCDBINSTALL INST , PS_RBD_CURRT CUR , PS_RSF_SUSER S , PS_RSF_SUSER MGR WHERE TF.TIMEFRAME_ID = Q.TIMEFRAME_ID AND TF.PERIOD_ID = Q.PERIOD_ROLLUP_ID AND TF.ROLLUP_SEQNUM = 2 AND S.PERSON_ID = Q.PERSON_ID AND Q.FORECAST_CATEGORY = 'R' AND ((Q.CURRENCY_CD = CUR.CURRENCY_CD AND Q.CURRENCY_CD <> ' ' ) OR (Q.CURRENCY_CD = ' ' AND S.CURRENCY_CD = CUR.CURRENCY_CD)) AND Q.FORECAST_CATEGORY = 'R' AND Q.PERSON_ID_MANAGER = MGR.PERSON_ID AND ((MGR.REV_QUOTA_TYPE = 'M' AND Q.PERSON_ID_MANAGER = Q.PERSON_ID) OR MGR.REV_QUOTA_TYPE = 'R') GROUP BY Q.PERSON_ID_MANAGER , Q.TIMEFRAME_ID , Q.PERIOD_ROLLUP_ID , INST.PT_CDB_DEF_CUR_CD, CUR.INST_MULT
|