Hi
I have copied a View that gives information from last month March and also for this year. I cannot figure out which part of the code is giving the result for last month. Could someone please let me know which part of the code is doing this. ( I need to alter the view but as soon as I take a filed out it is looking at all months) Thanks in advance
SELECT dbo.[148-vwSalesData].FinancialYear AS Year, dbo.[148-vwSalesData].Half, dbo.[148-vwSalesData].Quarter AS Qtr, dbo.[148-vwSalesData].MonthName AS Month, dbo.[148-vwSalesData].Quay, dbo.[148-vwSalesData].Product, dbo.[148-vwSalesData].OriginalRepArea AS [Rep Area], dbo.[148-vwSalesData].[Cust Code], dbo.[148-vwSalesData].[Cust Name], dbo.[148-vwSalesData].[Buying Group], dbo.[148-vwSalesData].Value, dbo.[148-vwSalesData].m3, dbo.[148-vwSalesData].[Sub-group], dbo.[148-vwSalesData].[Group], dbo.[148-ElapsedWorkingDays](dbo.[148-MakeDate](1, MONTH(GETDATE()), YEAR(GETDATE())), dbo.[148-MakeDate](DAY(GETDATE()), MONTH(GETDATE()), YEAR(GETDATE()))) AS ElapsedDays, dbo.[148-ElapsedWorkingDays](dbo.[148-MakeDate](1, MONTH(GETDATE()), YEAR(GETDATE())), dbo.[148-MakeDate](dbo.[148-LastDayInMonth](YEAR(GETDATE()), MONTH(GETDATE())), MONTH(GETDATE()), YEAR(GETDATE()))) AS TotalDays, dbo.[148-YearFinancials].Year AS Y, dbo.[148-YearFinancials].Month AS M, dbo.[148-vwSalesData].Rep_Corrected AS Rep
FROM dbo.[148-vwSalesData] WITH (NOLOCK) INNER JOIN dbo.[148-YearFinancials] WITH (NOLOCK) ON dbo.[148-vwSalesData].MonthName = dbo.[148-YearFinancials].PrevMonthName AND dbo.[148-vwSalesData].FinancialYear = dbo.[148-YearFinancials].PrevMonthFinancialYear
WHERE (dbo.[148-YearFinancials].Year = YEAR(GETDATE())) AND (dbo.[148-YearFinancials].Month = MONTH(GETDATE()))
I have copied a View that gives information from last month March and also for this year. I cannot figure out which part of the code is giving the result for last month. Could someone please let me know which part of the code is doing this. ( I need to alter the view but as soon as I take a filed out it is looking at all months) Thanks in advance
SELECT dbo.[148-vwSalesData].FinancialYear AS Year, dbo.[148-vwSalesData].Half, dbo.[148-vwSalesData].Quarter AS Qtr, dbo.[148-vwSalesData].MonthName AS Month, dbo.[148-vwSalesData].Quay, dbo.[148-vwSalesData].Product, dbo.[148-vwSalesData].OriginalRepArea AS [Rep Area], dbo.[148-vwSalesData].[Cust Code], dbo.[148-vwSalesData].[Cust Name], dbo.[148-vwSalesData].[Buying Group], dbo.[148-vwSalesData].Value, dbo.[148-vwSalesData].m3, dbo.[148-vwSalesData].[Sub-group], dbo.[148-vwSalesData].[Group], dbo.[148-ElapsedWorkingDays](dbo.[148-MakeDate](1, MONTH(GETDATE()), YEAR(GETDATE())), dbo.[148-MakeDate](DAY(GETDATE()), MONTH(GETDATE()), YEAR(GETDATE()))) AS ElapsedDays, dbo.[148-ElapsedWorkingDays](dbo.[148-MakeDate](1, MONTH(GETDATE()), YEAR(GETDATE())), dbo.[148-MakeDate](dbo.[148-LastDayInMonth](YEAR(GETDATE()), MONTH(GETDATE())), MONTH(GETDATE()), YEAR(GETDATE()))) AS TotalDays, dbo.[148-YearFinancials].Year AS Y, dbo.[148-YearFinancials].Month AS M, dbo.[148-vwSalesData].Rep_Corrected AS Rep
FROM dbo.[148-vwSalesData] WITH (NOLOCK) INNER JOIN dbo.[148-YearFinancials] WITH (NOLOCK) ON dbo.[148-vwSalesData].MonthName = dbo.[148-YearFinancials].PrevMonthName AND dbo.[148-vwSalesData].FinancialYear = dbo.[148-YearFinancials].PrevMonthFinancialYear
WHERE (dbo.[148-YearFinancials].Year = YEAR(GETDATE())) AND (dbo.[148-YearFinancials].Month = MONTH(GETDATE()))