Q&A for scientists using computers to solve scientific problems
SELECT ---https://stackoverflow.com/questions/1267126/get-the-week-start-date-and-week-end-date-from-week-number DATEADD(dd, -(DATEPART(dw, p.CreationDate)-1), CAST(p.CreationDate AS Date)) [WeekStart], COUNT(p.Id) AS [Spam Posts] FROM PostsWithDeleted p INNER JOIN Votes v ON v.PostId = p.Id WHERE v.VoteTypeId IN (##types?4,12##) AND p.DeletionDate IS NOT NULL AND (CAST(p.CreationDate AS Date)>= '##Date1?2021-01-01##') AND (CAST(p.CreationDate AS Date) <= '##Date2?2030-01-01##') GROUP BY DATEADD(dd, -(DATEPART(dw, p.CreationDate)-1), CAST(p.CreationDate AS Date)) ORDER BY DATEADD(dd, -(DATEPART(dw, p.CreationDate)-1), CAST(p.CreationDate AS Date))