Hi All,
I have the following query listed below
select DISTINCT -1, vODS_GLBalance_test.Page, vODS_GLBalance_test.FiscalYearId, vODS_GLBalance_test.FiscalMonthOfYearId, GLAmount From ODS.Staging.vODS_GLBalance_Test Left Outer Join Ods.JJill.tODS_GLBalance ON tODS_GLBalance.FiscalYearId = vODS_GLBalance_Test.FiscalYearId AND tODS_GLBalance.FiscalMonthOfYearId = vODS_GLBalance_Test.FiscalMonthOfYearId AND tODS_GLBalance.Page = vODS_GLBalance_Test.PAGE where vODS_GLBalance_Test.fiscalyearid = YEAR(GETDATE()) AND vODS_GLBalance_Test.fiscalMonthofyearId = MONTH(GETDATE())-1The query runs fine and gives me the exact data if we are in lets say 2014 and months > 3.But my issue here is i am using a fiscal calendar and fiscal calendar months is not always MONTH(GETDATE())-1, for ex if we are in feb 2014 then the logic above will give us Jan 2014 but it should give me jan 2013 as the fiscal year starts from feb and ends in jan.
Can someone please help me with any suggestions?
Thanks.