I am getting incorrect syntax error on =1on this line in where condition case:WHEN 1 THEN month(t.PctCompleteDate)=1Is it the proper way to have case statement within where condition?set @ProgID = 59set @yearnum = 2007set @QtrYearNum = 3SELECT t.ProgID, t.taskid,isnull(avg(t.PctComplete),0),isnull(avg(t.award_amt),0), ISNULL(SUM(c.amount),0) FROM TAB_ccsNetTasksLog t INNER JOIN tab_ccsnetcostdetails c ON (t.TaskID = c.TaskID and c.EstimateType ='Final' and c.COexecuted = 1 AND t.ProgID=@ProgID) Inner Join tab_ccsnetco co on (c.coid = co.coid and c.coexecuted=1) Where CASE @QtrYearNum WHEN 1 THEN month(t.PctCompleteDate)=1 or month(t.PctCompleteDate)=2 or month(t.PctCompleteDate)= 3 and year(t.PctCompleteDate) = @yearnum WHEN 2 THEN month(t.PctCompleteDate)= 4 or month(t.PctCompleteDate)= 5 or month(t.PctCompleteDate)= 6 and year(t.PctCompleteDate) = @yearnum WHEN 3 THEN month(t.PctCompleteDate)= 7 or month(t.PctCompleteDate)= 8 or month(t.PctCompleteDate)= 9 and year(t.PctCompleteDate) = @yearnum WHEN 4 THEN month(t.PctCompleteDate)=10 or month(t.PctCompleteDate)= 11 or month(t.PctCompleteDate)= 12 and year(t.PctCompleteDate) = @yearnum END GROUP BY t.ProgID, t.taskid, t.award_amt, t.Pctcomplete
Thank you very much for the helpful info.