One way is to join to a date table with one date for each month.create table #Month ( MonthStartDate datetime not null, NextMonthStartDate datetime not null primary key clustered)-- Create table of month start datesinsert into #Monthselect MonthStartDate = dateadd(mm,datediff(mm,0,getdate())+a.number,0), NextMonthStartDate = dateadd(mm,datediff(mm,0,getdate())+a.number+1,0)from -- Number Table Function available here -- http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47685 http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47685 dbo.F_TABLE_NUMBER_RANGE(-12,0) aorder by a.number select b.MonthStartDate, a.*from [Knowledge_Base] a join #t b on a.Date_Opened < b.NextMonthStartDate and (a.Closed >= b.NextMonthStartDate or a.Closed is null )order by b.MonthStartDate
CODO ERGO SUM