Q&A for professional and enthusiast programmers
DECLARE @Question tinyint = 1; DECLARE @Answer tinyint = 2; DECLARE @CloseVoteReview tinyint = 2; DECLARE @Invalid tinyint = 3; SELECT 'site://posts/' + CAST(PostId AS nvarchar) + '/timeline|' + p.Title as [TimeLine Link] FROM ReviewTasks r JOIN Posts p ON r.PostId = p.Id WHERE p.PostTypeId = @Question AND ( DATEDIFF(d, r.CreationDate, r.DeletionDate) = 14 OR DATEDIFF(d, r.CreationDate, r.DeletionDate) = 4 ) AND r.ReviewTaskTypeId = @CloseVoteReview AND r.ReviewTaskStateId = @Invalid AND YEAR(r.DeletionDate) = 2021 ORDER BY r.DeletionDate DESC;