I have a query that summarizes a calls taken during a week. I obtain a name then sum the totals for each week. a portion of the query is below. What I want to do is only include a certain amount of weeks back based on the current date. i.e. I want to exclude week 32 this week, week 32 and 33 next week. without having to modify my query each week. select d.lname + ', ' + d.fname 'agent',sum(Case when d.week = 32 then 1 else 0 end) '32',sum(Case when d.week = 33 then 1 else 0 end) '33',sum(Case when d.week = 34 then 1 else 0 end) '34',sum(Case when d.week = 35 then 1 else 0 end) '35',sum(Case when d.week = 36 then 1 else 0 end) '36',sum(Case when d.week = 37 then 1 else 0 end) '37',sum(Case when d.week = 38 then 1 else 0 end) '38',sum(Case when d.week = 39 then 1 else 0 end) '39',sum(Case when d.week = 40 then 1 else 0 end) '40',sum(Case when d.week = 41 then 1 else 0 end) '41',sum(Case when d.week = 42 then 1 else 0 end) '42',....from Table d ]
edit: fixed line breaks