Professional Documents
Culture Documents
GB Int
GB Int
FiscalPeriodStartDate ,
isd.FinancialAccountId ,
isd.FinancialAccountName ,
isd.FinancialAccountSubGroupName ,
isd.FinancialAccountGroupName ,
isd.FinancialReportBlock ,
isd.FinancialCompanyId ,
isd.FinancialCompanyId_Rollup ,
isd.FinancialCompanyDescription_Rollup ,
CombCompanyRollup,
isd.FinancialCompanyDescription ,
isd.FinancialProductId ,
isd.FinancialProductDescription ,
isd.FinancialDepartmentId ,
isd.FinancialDepartmentDesc ,
isd.FinancialDepartmentGroupId ,
isd.FinancialDepartmentGroupDesc,
isd.FinancialDepartmentParentId ,
isd.FinancialDepartmentParentDesc ,
isd.SeniorVicePresidentName,
isd.RegionalVicePresidentName,
isd.LocationId,
isd.LocationName,
isd.LedgerId,
isd.Country,
','+ac.ALL_Roles_Username+',' as UserNames,
isd.CYMTD_Accounted_Amt,
isd.CYMTD_Budget_Amt,
isd.PYMTD_Accounted_Amt
FROM
(SELECT FiscalPeriodStartDate ,
FinancialAccountId ,
FinancialAccountName ,
FinancialAccountSubGroupName ,
FinancialAccountGroupName ,
FinancialReportBlock ,
FinancialCompanyId ,
FinancialCompanyId_Rollup ,
FinancialCompanyDescription_Rollup ,
CombCompanyRollup,
FinancialCompanyDescription ,
FinancialProductId ,
FinancialProductDescription ,
FinancialDepartmentId ,
FinancialDepartmentDesc ,
FinancialDepartmentGroupId ,
FinancialDepartmentGroupDesc,
FinancialDepartmentParentId ,
FinancialDepartmentParentDesc ,
SeniorVicePresidentName,
RegionalVicePresidentName,
LocationId,
LocationName,
LedgerId,
Country,
SUM(CYMTD_Accounted_Amt) CYMTD_Accounted_Amt,
SUM(CYMTD_Budget_Amt) CYMTD_Budget_Amt,
SUM(PYMTD_Accounted_Amt) PYMTD_Accounted_Amt
from
(SELECT FiscalPeriodStartDate ,
FinancialAccountId ,
FinancialAccountName ,
FinancialAccountSubGroupName ,
FinancialAccountGroupName ,
FinancialReportBlock ,
FinancialCompanyId ,
FinancialCompanyId_Rollup ,
FinancialCompanyDescription_Rollup ,
CombCompanyRollup,
FinancialCompanyDescription ,
FinancialProductId ,
FinancialProductDescription ,
FinancialDepartmentId ,
FinancialDepartmentDesc ,
FinancialDepartmentGroupId ,
FinancialDepartmentGroupDesc,
FinancialDepartmentParentId ,
FinancialDepartmentParentDesc ,
SeniorVicePresidentName,
RegionalVicePresidentName,
LocationId,
LocationName,
LedgerId,
CASE When ct.EDWCodeTypeDesc IS NULL then 'Canada' else ct.EDWCodeType end
Country,
CASE When LedgerId=1 then CYMTD_Entered_Amt else CYMTD_Accounted_Amt end
CYMTD_Accounted_Amt,
CASE When LedgerId=1 then CYMTD_Entered_Budget_Amt else CYMTD_Budget_Amt end
CYMTD_Budget_Amt,
0 PYMTD_Accounted_Amt
UNION ALL
AND
(LedgerID=62 or (LedgerID=1 and FinancialCompanyId_Rollup in( select
EDWCodeTypeDesc
FROM [EDW_AnalyticsEDW].[dbo].[D_EDWCodeTypes]
where EDWCodeCategory = 'domesticFilter' and EDWCodeTypeExpDate = '2099-12-
31' and EDWActiveRecordInd = 1)))
)A ---- for calana or mexico
GROUP BY FiscalPeriodStartDate ,
FinancialAccountId ,
FinancialAccountName ,
FinancialAccountSubGroupName ,
FinancialAccountGroupName ,
FinancialReportBlock ,
FinancialCompanyId ,
FinancialCompanyId_Rollup ,
FinancialCompanyDescription_Rollup ,
CombCompanyRollup,
FinancialCompanyDescription ,
FinancialProductId ,
FinancialProductDescription ,
FinancialDepartmentId ,
FinancialDepartmentDesc ,
FinancialDepartmentGroupId ,
FinancialDepartmentGroupDesc,
FinancialDepartmentParentId ,
FinancialDepartmentParentDesc ,
SeniorVicePresidentName,
RegionalVicePresidentName,
LocationId,
LocationName,
LedgerId,
Country)isd
left outer join EDW_AnalyticsEDW.dbo.F_Access_control ac
on isd.LocationId=ac.LocationId
and isd.FinancialDepartmentId=ac.FinancialDepartmentId
and isd.LedgerId=ac.LedgerId