If you want to restrict the query to one year, include a WHERE clause as shown below.SELECT COUNT(*) AS NumberOfEvents, DATEPART(week, modifieddate) AS [WeekNumber]FROM Production.DocumentWHERE modifieddate > CAST(DATEADD(yy,-1,GETDATE()) AS DATE)GROUP BY DATEPART(week, modifieddate)
One other thing I must mention is that the result you get would be dependent on the datefirst setting of the session where the query is run (which defaults to the datefirst setting of the server if not explicitly set). If that is a consideration, there are other ways to get the results in a consistent manner, but if it is not, forget that I even said this.________________________________________-- Yes, I am indeed a fictional character.