Q&A for people studying math at any level and professionals in related fields
;with minmax as ( select min(creationdate) as mindate , max(deletiondate) as maxdate from reviewtasks where reviewtasktypeid = 2 -- close ), days as ( select distinct cast(creationdate as date) as utcdate from posts --where creationdate between (select mindate from minmax) -- and (select maxdate from minmax) ) select utcdate , count(*) as [# of tasks] from days d --inner join reviewtasks r --where r.reviewtasktypeid = 2 -- close --and d.utcdate between r.creationdate and r.deletiondate group by utcdate order by utcdate